| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Defender |
| 4 |
* Plugin URI: https://wpmudev.com/project/wp-defender/ |
| 5 |
* Version: 3.0.1 |
| 6 |
* Description: Get regular security scans, vulnerability reports, safety recommendations and customized hardening for your site in just a few clicks. Defender is the analyst and enforcer who never sleeps. |
| 7 |
* Author: WPMU DEV |
| 8 |
* Author URI: https://wpmudev.com/ |
| 9 |
* License: GNU General Public License (Version 2 - GPLv2) |
| 10 |
* Text Domain: wpdef |
| 11 |
* Network: true |
| 12 |
* Requires PHP: 7.2 |
| 13 |
*/ |
| 14 |
/* |
| 15 |
Copyright 2007-2022 Incsub (http://incsub.com) |
| 16 |
Author - Hoang Ngo, Anton Shulga |
| 17 |
|
| 18 |
This program is free software; you can redistribute it and/or modify |
| 19 |
it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by |
| 20 |
the Free Software Foundation. |
| 21 |
|
| 22 |
This program is distributed in the hope that it will be useful, |
| 23 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
GNU General Public License for more details. |
| 26 |
|
| 27 |
You should have received a copy of the GNU General Public License |
| 28 |
along with this program; if not, write to the Free Software |
| 29 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 30 |
*/ |
| 31 |
|
| 32 |
if ( ! defined( 'ABSPATH' ) ) { |
| 33 |
die; |
| 34 |
} |
| 35 |
if ( ! defined( 'DEFENDER_VERSION' ) ) { |
| 36 |
define( 'DEFENDER_VERSION', '3.0.1' ); |
| 37 |
} |
| 38 |
if ( ! defined( 'DEFENDER_DB_VERSION' ) ) { |
| 39 |
define( 'DEFENDER_DB_VERSION', '3.0.1' ); |
| 40 |
} |
| 41 |
if ( ! defined( 'DEFENDER_SUI' ) ) { |
| 42 |
define( 'DEFENDER_SUI', '2-12-8' ); |
| 43 |
} |
| 44 |
if ( ! defined( 'DEFENDER_PLUGIN_BASENAME' ) ) { |
| 45 |
define( 'DEFENDER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 46 |
} |
| 47 |
if ( ! defined( 'WP_DEFENDER_DIR' ) ) { |
| 48 |
define( 'WP_DEFENDER_DIR', plugin_dir_path( __FILE__ ) ); |
| 49 |
} |
| 50 |
if ( ! defined( 'WP_DEFENDER_FILE' ) ) { |
| 51 |
define( 'WP_DEFENDER_FILE', __FILE__ ); |
| 52 |
} |
| 53 |
if ( ! defined( 'WP_DEFENDER_MIN_PHP_VERSION' ) ) { |
| 54 |
define( 'WP_DEFENDER_MIN_PHP_VERSION', '7.2.0' ); |
| 55 |
} |
| 56 |
if ( ! defined( 'WP_DEFENDER_PRO_PATH' ) ) { |
| 57 |
define( 'WP_DEFENDER_PRO_PATH', 'wp-defender/wp-defender.php' ); |
| 58 |
} |
| 59 |
// If PHP version is downgraded while the plugin is running, deactivate the plugin. |
| 60 |
if ( version_compare( PHP_VERSION, WP_DEFENDER_MIN_PHP_VERSION, '<' ) ) { |
| 61 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 62 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 63 |
} |
| 64 |
if ( is_plugin_active( DEFENDER_PLUGIN_BASENAME ) ) { |
| 65 |
deactivate_plugins( DEFENDER_PLUGIN_BASENAME ); |
| 66 |
return; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Run upgrade process. |
| 72 |
* |
| 73 |
* @since 2.4.6 |
| 74 |
*/ |
| 75 |
if ( DEFENDER_PLUGIN_BASENAME !== plugin_basename( __FILE__ ) ) { |
| 76 |
$pro_installed = file_exists( WP_PLUGIN_DIR . '/' . WP_DEFENDER_PRO_PATH ); |
| 77 |
|
| 78 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 79 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 80 |
} |
| 81 |
|
| 82 |
if ( is_plugin_active( WP_DEFENDER_PRO_PATH ) ) { |
| 83 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 84 |
return; |
| 85 |
} elseif ( |
| 86 |
$pro_installed && |
| 87 |
! defined( 'WP_UNINSTALL_PLUGIN' ) && |
| 88 |
is_plugin_active( DEFENDER_PLUGIN_BASENAME ) |
| 89 |
) { |
| 90 |
deactivate_plugins( DEFENDER_PLUGIN_BASENAME ); |
| 91 |
activate_plugin( plugin_basename( __FILE__ ) ); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
require_once WP_DEFENDER_DIR . 'vendor/autoload.php'; |
| 96 |
// Load Action Scheduler package. |
| 97 |
if ( file_exists( WP_DEFENDER_DIR . 'vendor/woocommerce/action-scheduler/action-scheduler.php' ) ) { |
| 98 |
add_action( |
| 99 |
'plugins_loaded', |
| 100 |
function() { |
| 101 |
require_once WP_DEFENDER_DIR . 'vendor/woocommerce/action-scheduler/action-scheduler.php'; |
| 102 |
}, |
| 103 |
-10 // Don't change the priority to positive number, because to load this before AS initialized. |
| 104 |
); |
| 105 |
} |
| 106 |
|
| 107 |
require_once WP_DEFENDER_DIR . 'src/functions.php'; |
| 108 |
// Create container. |
| 109 |
$builder = new \DI\ContainerBuilder(); |
| 110 |
global $wp_defender_di; |
| 111 |
$wp_defender_di = $builder->build(); |
| 112 |
global $wp_defender_central; |
| 113 |
$wp_defender_central = new \WP_Defender\Central(); |
| 114 |
do_action( 'wp_defender' ); |
| 115 |
// Initialize bootstrap. |
| 116 |
require_once WP_DEFENDER_DIR . 'src/bootstrap.php'; |
| 117 |
$bootstrap = new \WP_Defender\Bootstrap(); |
| 118 |
$bootstrap->check_if_table_exists(); |
| 119 |
if ( method_exists( $bootstrap, 'includes' ) ) { |
| 120 |
$bootstrap->includes(); |
| 121 |
} |
| 122 |
|
| 123 |
add_action( 'init', [ ( new \WP_Defender\Upgrader() ), 'run' ] ); |
| 124 |
add_action( 'admin_enqueue_scripts', [ $bootstrap, 'register_assets' ] ); |
| 125 |
add_filter( 'admin_body_class', [ $bootstrap, 'add_sui_to_body' ], 99 ); |
| 126 |
|
| 127 |
register_deactivation_hook( __FILE__, [ $bootstrap, 'deactivation_hook' ] ); |
| 128 |
register_activation_hook( __FILE__, [ $bootstrap, 'activation_hook' ] ); |
| 129 |
|