PluginProbe
Shield Security – Smart Bot Blocking, Brute-Force Login Protection & File Scanning / trunk
Shield Security – Smart Bot Blocking, Brute-Force Login Protection & File Scanning vtrunk
22.1.11 22.2.0 22.1.1 22.1.2 22.1.3 22.0.7 22.0.5 8.0.0 8.0.2 8.1.1 8.2.3 8.3.0 8.4.4 8.5.7 8.6.3 8.7.0 9.0.4 9.1.0 9.2.1 trunk 1.0 1.9.2 10.0.3 10.1.6 10.2.6 All 124 releases
wp-simple-firewall / plugin_init.php

plugin_init.php in Shield Security – Smart Bot Blocking, Brute-Force Login Protection & File Scanning trunk, at plugin_init.php

73 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use FernleafSystems\Wordpress\Plugin\Shield\Controller;
4 use FernleafSystems\Wordpress\Services\Services;
5
6 if ( !\defined( 'ABSPATH' ) ) { exit(); }
7
8 /** @var string $rootFile */
9 global $oICWP_Wpsf;
10 if ( isset( $oICWP_Wpsf ) || empty( $rootFile ) ) {
11 return;
12 }
13
14 class ICWP_WPSF_Shield_Security {
15
16 private static ?ICWP_WPSF_Shield_Security $oInstance = null;
17
18 private Controller\Controller $con;
19
20 private function __construct( Controller\Controller $controller ) {
21 $this->con = $controller;
22 }
23
24 /**
25 * @throws \Exception
26 */
27 public function start() {
28 $this->con->boot();
29 }
30
31 public function getController() :Controller\Controller {
32 return Controller\Controller::GetInstance();
33 }
34
35 /**
36 * @throws \Exception
37 */
38 public static function GetInstance( ?Controller\Controller $con = null ) :\ICWP_WPSF_Shield_Security {
39 if ( \is_null( self::$oInstance ) ) {
40 if ( !$con instanceof Controller\Controller ) {
41 throw new \Exception( 'Trying to create a Shield Plugin instance without a valid Controller' );
42 }
43 self::$oInstance = new self( $con );
44 }
45 return self::$oInstance;
46 }
47 }
48
49 Services::GetInstance();
50
51 try {
52 $oICWP_Wpsf_Controller = Controller\Controller::GetInstance( $rootFile );
53 $oICWP_Wpsf = ICWP_WPSF_Shield_Security::GetInstance( $oICWP_Wpsf_Controller );
54 $oICWP_Wpsf->start();
55 }
56 catch ( Controller\Exceptions\VersionMismatchException $e ) {
57 add_action( 'admin_notices', function () {
58 echo sprintf( '<div class="notice error"><p>%s</p></div>',
59 'Shield Security: There appears to be a configuration issue - please reinstall the Shield Security plugin.' );
60 } );
61 }
62 catch ( Controller\Exceptions\PluginConfigInvalidException $e ) {
63 add_action( 'admin_notices', function () use ( $e ) {
64 echo sprintf( '<div class="notice error"><p>%s</p><p>%s</p></div>',
65 'Shield Security: Could not load the plugin modules configuration. Please refresh and if the problem persists, please reinstall the Shield plugin.',
66 $e->getMessage()
67 );
68 } );
69 }
70 catch ( \Exception $e ) {
71 error_log( 'Perhaps due to a failed upgrade, the Shield plugin failed to load certain component(s) - you should remove the plugin and reinstall.' );
72 error_log( $e->getMessage() );
73 }