1 | <?php |
||
20 | class Plugin_Storage { |
||
21 | |||
22 | const ACTIVE_PLUGINS_OPTION_NAME = 'jetpack_connection_active_plugins'; |
||
23 | |||
24 | /** |
||
25 | * Whether this class was configured for the first time or not. |
||
26 | * |
||
27 | * @var boolean |
||
28 | */ |
||
29 | private static $configured = false; |
||
30 | |||
31 | /** |
||
32 | * Refresh list of connected plugins upon intialization. |
||
33 | * |
||
34 | * @var boolean |
||
35 | */ |
||
36 | private static $refresh_connected_plugins = false; |
||
37 | |||
38 | /** |
||
39 | * Connected plugins. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | private static $plugins = array(); |
||
44 | |||
45 | /** |
||
46 | * Whether the plugins were configured. |
||
47 | * To make sure we don't call the configuration process again and again. |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | private static $plugins_configuration_finished = false; |
||
52 | |||
53 | /** |
||
54 | * Add or update the plugin information in the storage. |
||
55 | * |
||
56 | * @param string $slug Plugin slug. |
||
57 | * @param array $args Plugin arguments, optional. |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | public static function upsert( $slug, array $args = array() ) { |
||
71 | |||
72 | /** |
||
73 | * Retrieve the plugin information by slug. |
||
74 | * WARNING: the method cannot be called until Plugin_Storage::configure is called, which happens on plugins_loaded |
||
75 | * Even if you don't use Jetpack Config, it may be introduced later by other plugins, |
||
76 | * so please make sure not to run the method too early in the code. |
||
77 | * |
||
78 | * @param string $slug The plugin slug. |
||
79 | * |
||
80 | * @return array|null|WP_Error |
||
81 | */ |
||
82 | public static function get_one( $slug ) { |
||
91 | |||
92 | /** |
||
93 | * Retrieve info for all plugins that use the connection. |
||
94 | * WARNING: the method cannot be called until Plugin_Storage::configure is called, which happens on plugins_loaded |
||
95 | * Even if you don't use Jetpack Config, it may be introduced later by other plugins, |
||
96 | * so please make sure not to run the method too early in the code. |
||
97 | * |
||
98 | * @return array|WP_Error |
||
99 | */ |
||
100 | public static function get_all() { |
||
109 | |||
110 | /** |
||
111 | * Remove the plugin connection info from Jetpack. |
||
112 | * WARNING: the method cannot be called until Plugin_Storage::configure is called, which happens on plugins_loaded |
||
113 | * Even if you don't use Jetpack Config, it may be introduced later by other plugins, |
||
114 | * so please make sure not to run the method too early in the code. |
||
115 | * |
||
116 | * @param string $slug The plugin slug. |
||
117 | * |
||
118 | * @return bool|WP_Error |
||
119 | */ |
||
120 | public static function delete( $slug ) { |
||
133 | |||
134 | /** |
||
135 | * The method makes sure that `Jetpack\Config` has finished, and it's now safe to retrieve the list of plugins. |
||
136 | * |
||
137 | * @return bool|WP_Error |
||
138 | */ |
||
139 | private static function ensure_configured() { |
||
146 | |||
147 | /** |
||
148 | * Called once to configure this class after plugins_loaded. |
||
149 | * |
||
150 | * @return void |
||
151 | */ |
||
152 | public static function configure() { |
||
168 | |||
169 | /** |
||
170 | * Updates the active plugins option with current list of active plugins. |
||
171 | * |
||
172 | * @return void |
||
173 | */ |
||
174 | public static function update_active_plugins_option() { |
||
178 | |||
179 | } |
||
180 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.