-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
72 lines (60 loc) · 2.1 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
<?php
/*
Plugin Name: ChatBlend Live Chat
Plugin URI: https://github.com/starknine/chatblend-wp
Description: ChatBlend Live Chat Wordpress Plugin
Version: 0.1a
Author: Chris Flynn | Starknine
Author URI: http://starknine.com
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Access denied.' );
}
define( 'CB_NAME', 'ChatBlend Live Chat' );
define( 'CB_REQUIRED_PHP_VERSION', '5.3' ); // because of get_called_class()
define( 'CB_REQUIRED_WP_VERSION', '3.1' ); // because of esc_textarea()
/**
* Checks if the system requirements are met
*
* @return bool True if system requirements are met, false if not
*/
function cb_requirements_met() {
global $wp_version;
//require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); // to get is_plugin_active() early
if ( version_compare( PHP_VERSION, CB_REQUIRED_PHP_VERSION, '<' ) ) {
return false;
}
if ( version_compare( $wp_version, CB_REQUIRED_WP_VERSION, '<' ) ) {
return false;
}
/*
if ( ! is_plugin_active( 'plugin-directory/plugin-file.php' ) ) {
return false;
}
*/
return true;
}
/**
* Prints an error that the system requirements weren't met.
*/
function cb_requirements_error() {
global $wp_version;
require_once( dirname( __FILE__ ) . '/views/requirements-error.php' );
}
/*
* Check requirements and load 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 ( cb_requirements_met() ) {
require_once( __DIR__ . '/classes/cb-module.php' );
require_once( __DIR__ . '/classes/chatblend.php' );
require_once( __DIR__ . '/includes/admin-notice-helper/admin-notice-helper.php' );
require_once( __DIR__ . '/classes/cb-settings.php' );
if ( class_exists( 'ChatBlend' ) ) {
$GLOBALS['cb'] = ChatBlend::get_instance();
register_activation_hook( __FILE__, array( $GLOBALS['cb'], 'activate' ) );
register_deactivation_hook( __FILE__, array( $GLOBALS['cb'], 'deactivate' ) );
}
} else {
add_action( 'admin_notices', 'cb_requirements_error' );
}