PluginProbe
Manage – Centralized site maintenance and monitoring / 1.0.7
Manage – Centralized site maintenance and monitoring v1.0.7
1.0.9 1.0.8 1.0.7 1.0.6 1.0.5 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4
manage / plugin.php

plugin.php in Manage – Centralized site maintenance and monitoring 1.0.7, at plugin.php

74 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Manage;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 class Plugin {
9
10 public static $instance = null;
11
12 public $modules_manager = null;
13
14 private array $classes_aliases = [];
15
16 public static function instance(): ?Plugin {
17 if ( is_null( self::$instance ) ) {
18 self::$instance = new self();
19 }
20
21 return self::$instance;
22 }
23
24 public function autoload( $class ) {
25 if ( 0 !== strpos( $class, __NAMESPACE__ ) ) {
26 return;
27 }
28
29 $has_class_alias = isset( $this->classes_aliases[ $class ] );
30
31 // Backward Compatibility: Save old class name for set an alias after the new class is loaded
32 if ( $has_class_alias ) {
33 $class_alias_name = $this->classes_aliases[ $class ];
34 $class_to_load = $class_alias_name;
35 } else {
36 $class_to_load = $class;
37 }
38
39 if ( ! class_exists( $class_to_load ) ) {
40 $filename = strtolower(
41 preg_replace(
42 [ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ],
43 [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ],
44 $class_to_load
45 )
46 );
47 $filename = MANAGE_PATH . $filename . '.php';
48
49 if ( is_readable( $filename ) ) {
50 include $filename;
51 }
52 }
53
54 if ( $has_class_alias ) {
55 class_alias( $class_alias_name, $class );
56 }
57 }
58
59 private function includes() {
60 require_once MANAGE_PATH . 'includes/modules-manager.php';
61 $this->modules_manager = new Manager();
62 }
63
64 public function __construct() {
65 static $autoloader_registered = false;
66 if ( ! $autoloader_registered ) {
67 $autoloader_registered = spl_autoload_register( [ $this, 'autoload' ] );
68 }
69 $this->includes();
70 }
71 }
72
73 Plugin::instance();
74