1 | <?php |
||
22 | class Autoloader |
||
23 | { |
||
24 | /** @var array Store Autoloader cache and site option */ |
||
25 | private static $cache; |
||
26 | |||
27 | /** @var array Autoloaded plugins */ |
||
28 | private static $auto_plugins; |
||
29 | |||
30 | /** @var array Autoloaded mu-plugins */ |
||
31 | private static $mu_plugins; |
||
32 | |||
33 | /** @var int Number of plugins */ |
||
34 | private static $count; |
||
35 | |||
36 | /** @var array Newly activated plugins */ |
||
37 | private static $activated; |
||
38 | |||
39 | /** @var string Relative path to the mu-plugins dir */ |
||
40 | private static $relative_path; |
||
41 | |||
42 | /** @var static Singleton instance */ |
||
43 | private static $_single; |
||
44 | |||
45 | /** |
||
46 | * Create singleton, populate vars, and set WordPress hooks |
||
47 | */ |
||
48 | public function __construct() |
||
63 | |||
64 | /** |
||
65 | * Run some checks then autoload our plugins. |
||
66 | */ |
||
67 | public function loadPlugins() |
||
79 | |||
80 | /** |
||
81 | * Filter show_advanced_plugins to display the autoloaded plugins. |
||
82 | * @param $bool bool Whether to show the advanced plugins for the specified plugin type. |
||
83 | * @param $type string The plugin type, i.e., `mustuse` or `dropins` |
||
84 | * @return bool We return `false` to prevent WordPress from overriding our work |
||
85 | * {@internal We add the plugin details ourselves, so we return false to disable the filter.} |
||
86 | */ |
||
87 | public function showInAdmin($show, $type) |
||
108 | |||
109 | /** |
||
110 | * This sets the cache or calls for an update |
||
111 | */ |
||
112 | private function checkCache() |
||
124 | |||
125 | /** |
||
126 | * Get the plugins and mu-plugins from the mu-plugin path and remove duplicates. |
||
127 | * Check cache against current plugins for newly activated plugins. |
||
128 | * After that, we can update the cache. |
||
129 | */ |
||
130 | private function updateCache() |
||
143 | |||
144 | /** |
||
145 | * This accounts for the plugin hooks that would run if the plugins were |
||
146 | * loaded as usual. Plugins are removed by deletion, so there's no way |
||
147 | * to deactivate or uninstall. |
||
148 | */ |
||
149 | private function pluginHooks() |
||
159 | |||
160 | /** |
||
161 | * Check that the plugin file exists, if it doesn't update the cache. |
||
162 | */ |
||
163 | private function validatePlugins() |
||
172 | |||
173 | /** |
||
174 | * Count the number of autoloaded plugins. |
||
175 | * |
||
176 | * Count our plugins (but only once) by counting the top level folders in the |
||
177 | * mu-plugins dir. If it's more or less than last time, update the cache. |
||
178 | * |
||
179 | * @return int Number of autoloaded plugins. |
||
180 | */ |
||
181 | private function countPlugins() |
||
196 | } |
||
197 | |||
198 | new Autoloader(); |