Skip to content

Commit 3b88ced

Browse files
committed
fix: small tweaks to the dropin
1 parent 874ee15 commit 3b88ced

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

stubs/activate-ymir-plugin.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function activate_ymir_plugin() {
44
if (defined('WP_INSTALLING') && WP_INSTALLING) {
55
return;
66
} elseif (!function_exists('get_plugins')) {
7-
require_once ABSPATH . 'wp-admin/includes/plugin.php';
7+
require_once ABSPATH.'wp-admin/includes/plugin.php';
88
}
99

1010
// Important to not activate the plugin if it's already active. It's fine for normal sites, but
@@ -25,8 +25,12 @@ function activate_ymir_plugin() {
2525
/**
2626
* Ensures that the plugin is always the first one to be loaded per site.
2727
*/
28-
function ensure_ymir_plugin_loaded_first(array $active_plugins): array
28+
function ensure_ymir_plugin_loaded_first($active_plugins)
2929
{
30+
if (!is_array($active_plugins)) {
31+
return $active_plugins;
32+
}
33+
3034
foreach ($active_plugins as $key => $basename) {
3135
if (1 === preg_match('/ymir\.php$/', $basename)) {
3236
array_splice($active_plugins, $key, 1);
@@ -36,13 +40,17 @@ function ensure_ymir_plugin_loaded_first(array $active_plugins): array
3640

3741
return $active_plugins;
3842
}
39-
add_filter('pre_update_option_active_plugins', 'ensure_ymir_plugin_loaded_first', 9999);
43+
add_filter('pre_update_option_active_plugins', 'ensure_ymir_plugin_loaded_first', PHP_INT_MAX);
4044

4145
/**
4246
* Ensures that the plugin is always the first one to be loaded for the network.
4347
*/
44-
function ensure_ymir_plugin_loaded_first_on_network(array $active_plugins): array
48+
function ensure_ymir_plugin_loaded_first_on_network($active_plugins)
4549
{
50+
if (!is_array($active_plugins)) {
51+
return $active_plugins;
52+
}
53+
4654
$active_plugins = array_keys($active_plugins);
4755

4856
foreach ($active_plugins as $index => $plugin) {
@@ -54,4 +62,4 @@ function ensure_ymir_plugin_loaded_first_on_network(array $active_plugins): arra
5462

5563
return array_fill_keys($active_plugins, time());
5664
}
57-
add_filter('pre_update_site_option_active_sitewide_plugins', 'ensure_ymir_plugin_loaded_first_on_network', 9999);
65+
add_filter('pre_update_site_option_active_sitewide_plugins', 'ensure_ymir_plugin_loaded_first_on_network', PHP_INT_MAX);

0 commit comments

Comments
 (0)