-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.php
74 lines (61 loc) · 2.25 KB
/
bootstrap.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
<?php
/*
* Plugin Name: Compassionate Comments
* Plugin URI: https://wordpress.org/plugins/compassionate-comments/
* Description: Encourages commenters to re-phrase toxic comments to be kind instead.
* Version: 0.1
* Author: Ian Dunn
* Author URI: https://iandunn.name
*/
defined( 'WPINC' ) || die();
define( 'COMCON_VERSION', '0.1' );
define( 'COMCON_REQUIRED_PHP_VERSION', '5.6' ); // Because of WordPress minimum requirements.
define( 'COMCON_REQUIRED_WP_VERSION', '5.0' ); // Because of Gutenberg components.
/**
* Checks if the system requirements are met.
*
* @return bool True if system requirements are met, false if not
*/
function comcon_requirements_met() {
global $wp_version;
if ( version_compare( PHP_VERSION, COMCON_REQUIRED_PHP_VERSION, '<' ) ) {
return false;
}
if ( version_compare( $wp_version, COMCON_REQUIRED_WP_VERSION, '<' ) ) {
return false;
}
return true;
}
/**
* Prints an error that the system requirements weren't met.
*/
function comcon_requirements_error() {
global $wp_version;
require_once( dirname( __FILE__ ) . '/admin/requirements-error.php' );
}
/*
* Check requirements and load the main class
*
* The main program needs to be in a separate file that only gets loaded if the plugin requirements are met.
* Otherwise older PHP installations could crash when trying to parse it.
*/
if ( comcon_requirements_met() ) {
require_once( dirname( __FILE__ ) . '/common/common.php' );
/*
* This isn't really what `wp_is_json_request()` is meant for, but it's the best option until
* https://core.trac.wordpress.org/ticket/42061 is resolved.
*
* @todo Replace with `wp_doing_rest()` (or whatever) once that's available on minimum required WP version.
*/
if ( is_admin() || wp_is_json_request() ) {
require_once( dirname( __FILE__ ) . '/admin/admin.php' );
require_once( dirname( __FILE__ ) . '/admin/settings/settings.php' );
require_once( dirname( __FILE__ ) . '/admin/impact/impact.php' );
} else {
// todo does ^ guaranttet this this is only front end? not really, what can you check instead?
// no, it'll load for cron too. what about login?
require_once( dirname( __FILE__ ) . '/front-end/front-end.php' );
}
} else {
add_action( 'admin_notices', 'COMCON_requirements_error' );
}