-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbc-security.php
72 lines (61 loc) · 2.36 KB
/
bc-security.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: BC Security
* Plugin URI: https://github.com/chesio/bc-security
* Description: Helps keeping WordPress websites secure.
* Version: 0.26.0-dev
* Author: Česlav Przywara <[email protected]>
* Author URI: https://www.chesio.com
* Requires PHP: 8.1
* Requires at least: 6.4
* Tested up to: 6.7
* Text Domain: bc-security
* GitHub Plugin URI: https://github.com/chesio/bc-security
* Update URI: https://github.com/chesio/bc-security
*/
declare(strict_types=1);
if (version_compare(PHP_VERSION, '8.1', '<')) {
// Warn user that his/her PHP version is too low for this plugin to function.
add_action('admin_notices', function () {
echo '<div class="notice notice-error"><p>';
echo esc_html(
sprintf(
__('BC Security plugin requires PHP 8.1 to function properly, but you have version %s installed. The plugin has been auto-deactivated.', 'bc-security'),
PHP_VERSION
)
);
echo '</p></div>';
// Warn user that his/her PHP version is no longer supported.
echo '<div class="notice notice-warning"><p>';
echo sprintf(
__('PHP version %1$s is <a href="%2$s">no longer supported</a>. You should consider upgrading PHP on your webhost.', 'bc-security'),
PHP_VERSION,
'https://www.php.net/supported-versions.php'
);
echo '</p></div>';
// https://make.wordpress.org/plugins/2015/06/05/policy-on-php-versions/
if (isset($_GET['activate'])) {
unset($_GET['activate']);
}
}, 10, 0);
// Self deactivate.
add_action('admin_init', function () {
deactivate_plugins(plugin_basename(__FILE__));
}, 10, 0);
// Bail.
return;
}
// Register autoloader for this plugin.
require_once __DIR__ . '/autoload.php';
return call_user_func(function () {
// Construct plugin instance.
$bc_security = new \BlueChip\Security\Plugin(__FILE__, $GLOBALS['wpdb']);
// Register activation hook.
register_activation_hook(__FILE__, [$bc_security, 'activate']);
// Register deactivation hook.
register_deactivation_hook(__FILE__, [$bc_security, 'deactivate']);
// Boot up the plugin immediately after all plugins are loaded.
add_action('plugins_loaded', [$bc_security, 'load'], 0, 0);
// Return the instance.
return $bc_security;
});