Originally design to activate Andrew Norcross's Airplane Mode plugin (https://github.com/norcross/airplane-mode), this little script will allow you to activate a plugin when the WordPress admin plugin screen cannot be loaded, for whatever reason.

August 26, 2016 ยท View on GitHub

* { -webkit-font-smoothing: subpixel-antialiased; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; color:#444; font-size:14px; } body { padding:25px; text-align:center; margin:30px auto; width:800px; max-width:90%; overflow:auto; } '; // check to be sure the plugin is in the plugins folder if( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ){ printf( '%s has not been installed. Make sure you have uploaded/copied the plugin into the plugins folder (%s). If you have ensured this has been done correctly, double check that the plugin slug is correct: %s', $plugin_name, WP_PLUGIN_DIR, $plugin_slug ); exit(); } global $wpdb; // get active_plugins option value (serialized array) and unserialize it $select = "SELECT `option_value` FROM {$wpdb->options} WHERE `option_name` = 'active_plugins';"; $active_plugins = $wpdb->get_var( $select ); $active_plugins_array = unserialize( $active_plugins ); // make sure it's not already activated if( ! in_array( $plugin_slug, $active_plugins_array ) ){ // add airplane mode to the active plugins array $active_plugins_array[] = $plugin_slug; $active_plugins = serialize( $active_plugins_array ); // update options table $wpdb->update( $wpdb->options, array( 'option_value' => $active_plugins ), array( 'option_name' => 'active_plugins' )); // alert user of outcome echo $plugin_name . ' Activated!'; exit(); } // alert user of outcome echo $plugin_name . ' is already activated.'; exit();