← All changes
|
app/Services/PluginInstaller/BackgroundInstaller.php
+4
-3
1.4.1
→
1.6.5
View file →
| @@ -38,15 +38,16 @@ | ||
| 38 | 38 | $upgrader = new \WP_Upgrader($skin); |
| 39 | 39 | $installed_plugins = array_keys(\get_plugins()); |
| 40 | 40 | $plugin_slug = $plugin_to_install['repo-slug']; |
| 41 | 41 | $plugin_file = isset($plugin_to_install['file']) ? $plugin_to_install['file'] : $plugin_slug . '.php'; |
| 42 | + $plugin_basename = $plugin_slug . '/' . $plugin_file; | |
| 42 | 43 | $installed = false; |
| 43 | 44 | $activate = false; |
| 44 | 45 | |
| 45 | 46 | // See if the plugin is installed already. |
| 46 | - if (isset($installed_plugins[$plugin_file])) { | |
| 47 | + if (in_array($plugin_basename, $installed_plugins, true)) { | |
| 47 | 48 | $installed = true; |
| 48 | - $activate = !is_plugin_active($installed_plugins[$plugin_file]); | |
| 49 | + $activate = !is_plugin_active($plugin_basename); | |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | // Install this thing! |
| 52 | 53 | if (!$installed) { |
| @@ -125,9 +126,9 @@ | ||
| 125 | 126 | |
| 126 | 127 | // Activate this thing. |
| 127 | 128 | if ($activate) { |
| 128 | 129 | try { |
| 129 | - $result = activate_plugin($installed ? $installed_plugins[$plugin_file] : $plugin_slug . '/' . $plugin_file); | |
| 130 | + $result = activate_plugin($plugin_basename); | |
| 130 | 131 | |
| 131 | 132 | if (is_wp_error($result)) { |
| 132 | 133 | throw new \Exception(esc_html($result->get_error_message())); |
| 133 | 134 | } |