PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
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 6.3.0, at extra/hub-connector/connector.php

130 lines 2.8 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.1.0' );
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 // WPMU DEV Hosting should use WPMU DEV Dashboard, bail.
75 if ( ! empty( Connector\Data::get()->get_full_wpmu_dev_hosting_id() ) ) {
76 return;
77 }
78
79 // Init classes.
80 Connector\Rest::get();
81 Connector\Admin::get();
82 Connector\Remote::get();
83 Connector\Actions::get();
84 }
85
86 /**
87 * Set options for plugin.
88 *
89 * @since 1.0.0
90 *
91 * @param string $plugin Plugin identifier.
92 * @param array $options Options.
93 *
94 * @return void
95 */
96 public function set_options( string $plugin, array $options = array() ) {
97 Connector\Admin::get()->set_plugin_options( $plugin, $options );
98 }
99
100 /**
101 * Autoload class files for the module.
102 *
103 * @since 1.0.0
104 *
105 * @param string $class_name Class name to autoload.
106 */
107 public function autoload( string $class_name ) {
108 // Project-specific namespace prefix.
109 $prefix = 'WPMUDEV\\Hub\\Connector\\';
110
111 // Does the class use the namespace prefix?
112 $len = strlen( $prefix );
113
114 // Get the relative class name.
115 $relative_class = substr( $class_name, $len );
116
117 if ( ! empty( $relative_class ) ) {
118 $path = explode( '\\', strtolower( str_replace( '_', '-', $relative_class ) ) );
119 $file = array_pop( $path );
120 $file = __DIR__ . '/inc/class-' . $file . '.php';
121
122 // If the file exists, require it.
123 if ( file_exists( $file ) ) {
124 require_once $file;
125 }
126 }
127 }
128 }
129 }
130