Skip to content

Commit a5055be

Browse files
committed
fix: add a filter to fool network installation
1 parent b9918ba commit a5055be

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

stubs/activate-ymir-plugin.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ function ymir_ensure_plugin_loaded_first_on_network($active_plugins)
6464
}
6565
add_filter('pre_update_site_option_active_sitewide_plugins', 'ymir_ensure_plugin_loaded_first_on_network', PHP_INT_MAX);
6666

67+
/**
68+
* Removes the Ymir plugin from the list of active plugins to fool network installation.
69+
*/
70+
function ymir_remove_plugin_from_active_plugins_when_installing_network($value)
71+
{
72+
// Return early if we're not installing the network or didn't deactivate all the other plugins.
73+
if (!defined('WP_INSTALLING_NETWORK') || !WP_INSTALLING_NETWORK || !is_array($value) || 1 !== count($value)) {
74+
return $value;
75+
}
76+
77+
$backtrace = debug_backtrace();
78+
$backtrace = end($backtrace);
79+
80+
return (!isset($backtrace['function']) || 'network_step1' !== $backtrace['function']) ? $value : [];
81+
}
82+
add_filter('option_active_plugins', 'ymir_remove_plugin_from_active_plugins_when_installing_network');
83+
6784
/**
6885
* Load Ymir plugin right away if it's in "mu-plugins".
6986
*/

0 commit comments

Comments
 (0)