PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.2
Defender Security – Malware Scanner, Login Security & Firewall v5.7.2
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / extra / hub-connector / connector.php

connector.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.2, at extra/hub-connector/connector.php

125 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPMUDEV Hub Connector module for free plugins.
4 *
5 * Used by wordpress.org hosted plugins to connect with the Hub.
6 *
7 * @since 1.0.0
8 * @author Joel James
9 * @package WPMUDEV\Hub\Connector
10 */
11
12 namespace WPMUDEV\Hub;
13
14 // Base file.
15 if ( ! defined( '\WPMUDEV_HUB_CONNECTOR_FILE' ) ) {
16 define( 'WPMUDEV_HUB_CONNECTOR_FILE', __FILE__ );
17 }
18
19 // Module version.
20 if ( ! defined( '\WPMUDEV_HUB_CONNECTOR_VERSION' ) ) {
21 define( 'WPMUDEV_HUB_CONNECTOR_VERSION', '1.0.8' );
22 }
23
24 // SUI version.
25 if ( ! defined( '\WPMUDEV_HUB_CONNECTOR_SUI_VERSION' ) ) {
26 define( 'WPMUDEV_HUB_CONNECTOR_SUI_VERSION', 'sui-2-12-24' );
27 }
28
29 if ( ! class_exists( '\WPMUDEV\Hub\Connector' ) ) {
30 /**
31 * Class Connector.
32 */
33 final class Connector {
34
35 /**
36 * Instance holder.
37 *
38 * @var Connector $instance
39 */
40 private static $instance;
41
42 /**
43 * Instance obtaining method.
44 *
45 * @since 1.0.0
46 *
47 * @return static Called class instance.
48 */
49 public static function get(): Connector {
50 // Only if not already exist.
51 if ( ! self::$instance instanceof Connector ) {
52 self::$instance = new Connector();
53 }
54
55 return self::$instance;
56 }
57
58 /**
59 * Initialize the module.
60 *
61 * @since 1.0.0
62 *
63 * @return void
64 */
65 protected function __construct() {
66 // Auto loader.
67 spl_autoload_register( array( $this, 'autoload' ) );
68
69 // Dashboard is active, bail.
70 if ( class_exists( 'WPMUDEV_Dashboard' ) ) {
71 return;
72 }
73
74 // Init classes.
75 Connector\Rest::get();
76 Connector\Admin::get();
77 Connector\Remote::get();
78 Connector\Actions::get();
79 }
80
81 /**
82 * Set options for plugin.
83 *
84 * @since 1.0.0
85 *
86 * @param string $plugin Plugin identifier.
87 * @param array $options Options.
88 *
89 * @return void
90 */
91 public function set_options( string $plugin, array $options = array() ) {
92 Connector\Admin::get()->set_plugin_options( $plugin, $options );
93 }
94
95 /**
96 * Autoload class files for the module.
97 *
98 * @since 1.0.0
99 *
100 * @param string $class_name Class name to autoload.
101 */
102 public function autoload( string $class_name ) {
103 // Project-specific namespace prefix.
104 $prefix = 'WPMUDEV\\Hub\\Connector\\';
105
106 // Does the class use the namespace prefix?
107 $len = strlen( $prefix );
108
109 // Get the relative class name.
110 $relative_class = substr( $class_name, $len );
111
112 if ( ! empty( $relative_class ) ) {
113 $path = explode( '\\', strtolower( str_replace( '_', '-', $relative_class ) ) );
114 $file = array_pop( $path );
115 $file = __DIR__ . '/inc/class-' . $file . '.php';
116
117 // If the file exists, require it.
118 if ( file_exists( $file ) ) {
119 require_once $file;
120 }
121 }
122 }
123 }
124 }
125