- $current = get_option('active_plugins');
- $plugin = $file;
- if ( validate_file($plugin) )
- wp_die(__('Invalid plugin.'));
- if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
- wp_die(__('Plugin file does not exist.'));
- if (!in_array($plugin, $current)) {
- wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error
- @include(ABSPATH . PLUGINDIR . '/' . $plugin);
- $current[] = $plugin;
- sort($current);
- update_option('active_plugins', $current);
- }
+
+ $error = validate_plugin($file);
+ if( is_wp_error($error) )
+ wp_die( $error );
+
+ if ( ! is_plugin_active($file) )
+ activate_plugin($file, "plugin-editor.php?file=$file&phperror=1");// we'll override this later if the plugin can be included without fatal error
+