Index: wp-admin/plugin-editor.php
===================================================================
--- wp-admin/plugin-editor.php	(revision 24532)
+++ wp-admin/plugin-editor.php	(working copy)
@@ -27,11 +27,13 @@
 if ( empty($plugins) )
 	wp_die( __('There are no plugins installed on this site.') );
 
-if ( $file ) {
-	$plugin = $file;
-} elseif ( empty( $plugin ) ) {
-	$plugin = array_keys($plugins);
-	$plugin = $plugin[0];
+if ( empty( $plugin ) ) {
+	if ( $file ) {
+		$plugin = $file;
+	} else {
+		$plugin = array_keys( $plugins );
+		$plugin = $plugin[0];
+	}
 }
 
 $plugin_files = get_plugin_files($plugin);
@@ -49,28 +51,27 @@
 
 	check_admin_referer('edit-plugin_' . $file);
 
-	$newcontent = wp_unslash( $_POST['newcontent'] );
-	if ( is_writeable($real_file) ) {
-		$f = fopen($real_file, 'w+');
-		fwrite($f, $newcontent);
-		fclose($f);
+	if ( is_writeable( $real_file ) ) {
+		$newcontent = wp_unslash( $_POST['newcontent'] );
 
-		$network_wide = is_plugin_active_for_network( $file );
+		file_put_contents($real_file, $newcontent); 
 
+		$network_wide = is_plugin_active_for_network( $plugin  );
+// @TODO: Network Wide activated plugins do not go through this lint check
 		// Deactivate so we can test it.
-		if ( is_plugin_active($file) || isset($_POST['phperror']) ) {
-			if ( is_plugin_active($file) )
-				deactivate_plugins($file, true);
+		if ( is_plugin_active($plugin) || isset($_POST['phperror']) ) {
+			if ( is_plugin_active($plugin) )
+				deactivate_plugins($plugin, true);
 
 			if ( ! is_network_admin() )
-				update_option( 'recently_activated', array( $file => time() ) + (array) get_option( 'recently_activated' ) );
+				update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
 
-			wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
+			wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&plugin=$plugin&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
 			exit;
 		}
-		wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
+		wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&updated=1&scrollto=$scrollto") );
 	} else {
-		wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") );
+		wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&scrollto=$scrollto") );
 	}
 	exit;
 
@@ -81,14 +82,14 @@
 	if ( isset($_GET['liveupdate']) ) {
 		check_admin_referer('edit-plugin-test_' . $file);
 
-		$error = validate_plugin($file);
+		$error = validate_plugin($plugin);
 		if ( is_wp_error($error) )
 			wp_die( $error );
 
-		if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) )
-			activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error
+		if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($plugin) ) || ! is_plugin_active($plugin) )
+			activate_plugin($plugin, "plugin-editor.php?file=$file&plugin=$plugin&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error
 
-		wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
+		wp_redirect( self_admin_url("plugin-editor.php?file=$file&plugin=$plugin&updated=1&scrollto=$scrollto") );
 		exit;
 	}
 
@@ -97,14 +98,14 @@
 	$editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions);
 
 	if ( ! is_file($real_file) ) {
-		wp_die(sprintf('<p>%s</p>', __('No such file exists! Double check the name and try again.')));
+		wp_die( __('No such file exists! Double check the name and try again.') );
 	} else {
 		// Get the extension of the file
 		if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) {
 			$ext = strtolower($matches[1]);
 			// If extension is not in the acceptable list, skip it
 			if ( !in_array( $ext, $editable_extensions) )
-				wp_die(sprintf('<p>%s</p>', __('Files of this type are not editable.')));
+				wp_die( __('Files of this type are not editable.') );
 		}
 	}
 
@@ -129,7 +130,7 @@
 
 	require_once(ABSPATH . 'wp-admin/admin-header.php');
 
-	update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
+	update_recently_edited( WP_PLUGIN_DIR . '/' . $plugin );
 
 	$content = file_get_contents( $real_file );
 
@@ -148,13 +149,14 @@
 
 	$content = esc_textarea( $content );
 	?>
-<?php if (isset($_GET['a'])) : ?>
+<?php if (isset($_GET['updated'])) : ?>
  <div id="message" class="updated"><p><?php _e('File edited successfully.') ?></p></div>
 <?php elseif (isset($_GET['phperror'])) : ?>
  <div id="message" class="updated"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p>
 	<?php
-		if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $file) ) { ?>
-	<iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&amp;plugin=<?php echo esc_attr($file); ?>&amp;_wpnonce=<?php echo esc_attr($_GET['_error_nonce']); ?>"></iframe>
+		if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) { 
+		//@TODO: Is this Network Admin safe? (admin_url()) ?>
+	<iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . urlencode($plugin) . '&_wpnonce=' . urlencode($_GET['_error_nonce']) ); ?>"></iframe>
 	<?php } ?>
 </div>
 <?php endif; ?>
@@ -165,7 +167,7 @@
 <div class="fileedit-sub">
 <div class="alignleft">
 <big><?php
-	if ( is_plugin_active($plugin) ) {
+	if ( is_plugin_active( $plugin ) || is_plugin_active_for_network( $plugin ) ) {
 		if ( is_writeable($real_file) )
 			echo sprintf(__('Editing <strong>%s</strong> (active)'), $file);
 		else
@@ -193,6 +195,7 @@
 		$plugin_key = esc_attr($plugin_key);
 		echo "\n\t<option value=\"$plugin_key\" $selected>$plugin_name</option>";
 	}
+
 ?>
 		</select>
 		<?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
@@ -234,7 +237,7 @@
 		<div id="documentation" class="hide-if-no-js"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Look Up' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" /></div>
 		<?php endif; ?>
 <?php if ( is_writeable($real_file) ) : ?>
-	<?php if ( in_array( $file, (array) get_option( 'active_plugins', array() ) ) ) { ?>
+	<?php if ( is_plugin_active( $plugin ) || is_plugin_active_for_network( $plugin ) ) { ?>
 		<p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p>
 	<?php } ?>
 	<p class="submit">
