-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
87 lines (81 loc) · 2.24 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Analytica core
*
* @package Analytica
* @since 1.0.0
*/
/**
* Analytica check PHP version.
*
* Check when the site doesn't have the minimum required PHP version.
*
* @since 1.0.0
*
* @return void
*/
function analytica_is_php_version_compatible() {
if ( ! version_compare( PHP_VERSION, '5.4', '>=' ) ) {
return false;
}
return true;
}
/**
* Analytica admin notice for minimum PHP version.
*
* Warning when the site doesn't have the minimum required PHP version.
*
* @since 1.0.0
*
* @return void
*/
function analytica_fail_php_version() {
/* translators: %s: PHP version */
$message = sprintf( esc_html__( 'Analytica requires PHP version %s+, theme is currently NOT ACTIVE.', 'analytica' ), '5.4' );
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message );
}
/**
* Analytica admin notice for minimum WordPress version.
*
* Warning when the site doesn't have the minimum required WordPress version.
*
* @since 1.5.0
*
* @return void
*/
function analytica_fail_wp_version() {
/* translators: %s: WordPress version */
$message = sprintf( esc_html__( 'Analytica requires WordPress version %s+. Because you are using an earlier version, the theme is currently NOT ACTIVE.', 'analytica' ), '4.7' );
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message );
}
if ( ! analytica_is_php_version_compatible() ) {
add_action( 'admin_notices', 'analytica_fail_php_version' );
return;
} elseif ( ! version_compare( get_bloginfo( 'version' ), '4.7', '>=' ) ) {
add_action( 'admin_notices', 'analytica_fail_wp_version' );
return;
} else {
require_once get_theme_file_path( '/includes/classes/core.php' );
}
/**
* The main function responsible for returning the one true analytica Instance
* to functions everywhere.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* Thanks bbpress :)
*
* Example: <?php $core = analytica(); ?>
*
* @return The one true analytica Instance
*/
function analytica() {
if ( ! analytica_is_php_version_compatible() ) {
return;
}
return \Analytica\Core::instance();
}
analytica(); // All systems go