forked from pressbooks/pressbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompatibility.php
68 lines (58 loc) · 1.87 KB
/
compatibility.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
<?php
/**
* Ensures compatibility between Pressbooks and the server environment
*
* @package Pressbooks
* @author Book Oven Inc. <[email protected]>
* @license GPLv2 (or any later version)
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Check if installation environment meets minimum PB requirements. Can be used by other plugins that depend on Pressbooks. Example usage: https://gist.github.com/greatislander/403f63ae466a166255c65d9e4e3edd20
*
* @return bool
*/
function pb_meets_minimum_requirements() {
$is_compatible = true;
// PHP Version
global $pb_minimum_php;
$pb_minimum_php = '5.6.0';
if ( ! version_compare( PHP_VERSION, $pb_minimum_php, '>=' ) ) {
add_action( 'admin_notices', '_pb_minimum_php' );
$is_compatible = false;
}
// WordPress Version
global $pb_minimum_wp;
$pb_minimum_wp = '4.7.4';
if ( ! is_multisite() || ! version_compare( get_bloginfo( 'version' ), $pb_minimum_wp, '>=' ) ) {
add_action( 'admin_notices', '_pb_minimum_wp' );
$is_compatible = false;
}
return $is_compatible;
}
/**
* Echo message about minimum PHP Version
*/
function _pb_minimum_php() {
global $pb_minimum_php;
echo '<div id="message" class="error fade"><p>';
printf(
esc_attr__( 'Pressbooks will not work with your version of PHP. Pressbooks requires PHP version %s or greater. Please upgrade PHP if you would like to use Pressbooks.', 'pressbooks' ),
esc_attr( $pb_minimum_php )
);
echo '</p></div>';
}
/**
* Echo message about minimum WordPress Version
*/
function _pb_minimum_wp() {
global $pb_minimum_wp;
echo '<div id="message" class="error fade"><p>';
printf(
esc_attr__( 'Pressbooks will not work with your version of WordPress. Pressbooks requires a dedicated install of WordPress Multisite, version %s or greater. Please upgrade WordPress if you would like to use Pressbooks.', 'pressbooks' ),
esc_attr( $pb_minimum_wp )
);
echo '</p></div>';
}