Refactor mu-plugin logic a bit by extracting a method.

This commit is contained in:
Yahnis Elsts 2016-01-09 20:10:10 +02:00
parent a26064220b
commit 8ecc66c848
1 changed files with 12 additions and 2 deletions

View File

@ -72,7 +72,7 @@ class PluginUpdateChecker_2_3 {
//Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume
//it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir).
if ( empty($this->muPluginFile) && (strpbrk($this->pluginFile, '/\\') === false) && $this->isMuPlugin() ) {
if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) {
$this->muPluginFile = $this->pluginFile;
}
@ -551,7 +551,7 @@ class PluginUpdateChecker_2_3 {
//No update notifications for mu-plugins unless explicitly enabled. The MU plugin file
//is usually different from the main plugin file so the update wouldn't show up properly anyway.
if ( !empty($update) && empty($this->muPluginFile) && $this->isMuPlugin() ) {
if ( $this->isUnknownMuPlugin() ) {
$update = null;
}
@ -901,6 +901,16 @@ class PluginUpdateChecker_2_3 {
return $cachedResult;
}
/**
* MU plugins are partially supported, but only when we know which file in mu-plugins
* corresponds to this plugin.
*
* @return bool
*/
protected function isUnknownMuPlugin() {
return empty($this->muPluginFile) && $this->isMuPlugin();
}
/**
* Clear the cached plugin version. This method can be set up as a filter (hook) and will
* return the filter argument unmodified.