<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[17033] trunk/wp-admin:
  Remove the delete action link from the network admin if the plugin is active on the main site
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17033">17033</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-12-17 21:53:47 +0000 (Fri, 17 Dec 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove the delete action link from the network admin if the plugin is active on the main site.  Remove the plugin(s) from the deletion list for the bulk actions and shows an error if no other plugin was selected for bulk-deletion. Props PeteMall. see <a href="http://trac.wordpress.org/ticket/15709">#15709</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswppluginslisttablephp">trunk/wp-admin/includes/class-wp-plugins-list-table.php</a></li>
<li><a href="#trunkwpadminpluginsphp">trunk/wp-admin/plugins.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswppluginslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-plugins-list-table.php (17032 => 17033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-plugins-list-table.php        2010-12-17 21:48:30 UTC (rev 17032)
+++ trunk/wp-admin/includes/class-wp-plugins-list-table.php        2010-12-17 21:53:47 UTC (rev 17033)
</span><span class="lines">@@ -362,7 +362,7 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         if ( current_user_can( 'manage_network_plugins' ) )
</span><span class="cx">                                                 $actions['network_activate'] = '&lt;a href=&quot;' . wp_nonce_url('plugins.php?action=activate&amp;amp;networkwide=1&amp;amp;plugin=' . $plugin_file . '&amp;amp;plugin_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '&quot; title=&quot;' . __('Activate this plugin for all sites in this network') . '&quot; class=&quot;edit&quot;&gt;' . __('Network Activate') . '&lt;/a&gt;';
</span><del>-                                        if ( current_user_can('delete_plugins') )
</del><ins>+                                        if ( current_user_can( 'delete_plugins' ) &amp;&amp; ! is_plugin_active( $plugin_file ) )
</ins><span class="cx">                                                 $actions['delete'] = '&lt;a href=&quot;' . wp_nonce_url('plugins.php?action=delete-selected&amp;amp;checked[]=' . $plugin_file . '&amp;amp;plugin_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'bulk-plugins') . '&quot; title=&quot;' . __('Delete this plugin') . '&quot; class=&quot;delete&quot;&gt;' . __('Delete') . '&lt;/a&gt;';
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span></span></pre></div>
<a id="trunkwpadminpluginsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugins.php (17032 => 17033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugins.php        2010-12-17 21:48:30 UTC (rev 17032)
+++ trunk/wp-admin/plugins.php        2010-12-17 21:53:47 UTC (rev 17033)
</span><span class="lines">@@ -195,12 +195,17 @@
</span><span class="cx"> 
</span><span class="cx">                         //$_POST = from the plugin form; $_GET = from the FTP details screen.
</span><span class="cx">                         $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
</span><del>-                        $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
-                        if ( empty($plugins) ) {
</del><ins>+                        if ( empty( $plugins ) ) {
</ins><span class="cx">                                 wp_redirect( self_admin_url(&quot;plugins.php?plugin_status=$status&amp;paged=$page&amp;s=$s&quot;) );
</span><span class="cx">                                 exit;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><ins>+                        $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
+                        if ( empty( $plugins ) ) {
+                                wp_redirect( self_admin_url( &quot;plugins.php?error=true&amp;main=true&amp;plugin_status=$status&amp;paged=$page&amp;s=$s&quot; ) );
+                                exit;
+                        }
+
</ins><span class="cx">                         include(ABSPATH . 'wp-admin/update.php');
</span><span class="cx"> 
</span><span class="cx">                         $parent_file = 'plugins.php';
</span><span class="lines">@@ -330,14 +335,16 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php if ( isset($_GET['error']) ) :
</span><span class="cx"> 
</span><del>-        if ( isset($_GET['charsout']) )
</del><ins>+        if ( isset( $_GET['main'] ) )
+                $errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
+        elseif ( isset($_GET['charsout']) )
</ins><span class="cx">                 $errmsg = sprintf(__('The plugin generated %d characters of &lt;strong&gt;unexpected output&lt;/strong&gt; during activation.  If you notice &amp;#8220;headers already sent&amp;#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
</span><span class="cx">         else
</span><span class="cx">                 $errmsg = __('Plugin could not be activated because it triggered a &lt;strong&gt;fatal error&lt;/strong&gt;.');
</span><span class="cx">         ?&gt;
</span><span class="cx">         &lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;&lt;?php echo $errmsg; ?&gt;&lt;/p&gt;
</span><span class="cx">         &lt;?php
</span><del>-                if ( !isset($_GET['charsout']) &amp;&amp; wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?&gt;
</del><ins>+                if ( !isset( $_GET['main'] ) &amp;&amp; !isset($_GET['charsout']) &amp;&amp; wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?&gt;
</ins><span class="cx">         &lt;iframe style=&quot;border:0&quot; width=&quot;100%&quot; height=&quot;70px&quot; src=&quot;&lt;?php echo 'plugins.php?action=error_scrape&amp;amp;plugin=' . esc_attr($plugin) . '&amp;amp;_wpnonce=' . esc_attr($_GET['_error_nonce']); ?&gt;&quot;&gt;&lt;/iframe&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>

</body>
</html>