<!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>[15642] trunk/wp-admin: Introduce WP_List_Table::current_action()
  and use throughout admin list screens.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15642">15642</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-09-22 00:10:39 +0000 (Wed, 22 Sep 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce WP_List_Table::current_action() and use throughout admin list screens. See <a href="http://trac.wordpress.org/ticket/14579">#14579</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditcommentsphp">trunk/wp-admin/edit-comments.php</a></li>
<li><a href="#trunkwpadminedittagsphp">trunk/wp-admin/edit-tags.php</a></li>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.php</a></li>
<li><a href="#trunkwpadminincludesdefaultlisttablesphp">trunk/wp-admin/includes/default-list-tables.php</a></li>
<li><a href="#trunkwpadminincludeslisttablephp">trunk/wp-admin/includes/list-table.php</a></li>
<li><a href="#trunkwpadminlinkmanagerphp">trunk/wp-admin/link-manager.php</a></li>
<li><a href="#trunkwpadminpluginsphp">trunk/wp-admin/plugins.php</a></li>
<li><a href="#trunkwpadminuploadphp">trunk/wp-admin/upload.php</a></li>
<li><a href="#trunkwpadminusersphp">trunk/wp-admin/users.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-comments.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-comments.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/edit-comments.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -12,20 +12,21 @@
</span><span class="cx"> $wp_list_table = get_list_table('comments');
</span><span class="cx"> $wp_list_table-&gt;check_permissions();
</span><span class="cx"> 
</span><del>-if ( isset( $_REQUEST['doaction'] ) ||  isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
</del><ins>+$doaction = $wp_list_table-&gt;current_action();
+
+if ( $doaction ) {
</ins><span class="cx">         check_admin_referer( 'bulk-comments' );
</span><span class="cx"> 
</span><del>-        if ( ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) &amp;&amp; !empty( $_REQUEST['pagegen_timestamp'] ) ) {
</del><ins>+        if ( 'delete_all' == $do_action &amp;&amp; !empty( $_REQUEST['pagegen_timestamp'] ) ) {
</ins><span class="cx">                 $comment_status = $wpdb-&gt;escape( $_REQUEST['comment_status'] );
</span><span class="cx">                 $delete_time = $wpdb-&gt;escape( $_REQUEST['pagegen_timestamp'] );
</span><span class="cx">                 $comment_ids = $wpdb-&gt;get_col( &quot;SELECT comment_ID FROM $wpdb-&gt;comments WHERE comment_approved = '$comment_status' AND '$delete_time' &gt; comment_date_gmt&quot; );
</span><span class="cx">                 $doaction = 'delete';
</span><del>-        } elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) &amp;&amp; isset( $_REQUEST['delete_comments'] ) ) {
</del><ins>+        } elseif ( isset( $_REQUEST['delete_comments'] ) ) {
</ins><span class="cx">                 $comment_ids = $_REQUEST['delete_comments'];
</span><span class="cx">                 $doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
</span><del>-        } elseif ( $_REQUEST['doaction'] == 'undo' &amp;&amp; isset( $_REQUEST['ids'] ) ) {
</del><ins>+        } elseif ( isset( $_REQUEST['ids'] ) ) {
</ins><span class="cx">                 $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
</span><del>-                $doaction = $_REQUEST['action'];
</del><span class="cx">         } else {
</span><span class="cx">                 wp_redirect( wp_get_referer() );
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkwpadminedittagsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-tags.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-tags.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/edit-tags.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -22,11 +22,8 @@
</span><span class="cx">         $submenu_file = &quot;edit-tags.php?taxonomy=$taxonomy&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-if ( isset( $_REQUEST['action'] ) &amp;&amp; isset( $_REQUEST['delete_tags'] ) &amp;&amp; ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
-        $action = 'bulk-delete';
</del><ins>+switch ( $wp_list_table-&gt;current_action() ) {
</ins><span class="cx"> 
</span><del>-switch ( $action ) {
-
</del><span class="cx"> case 'add-tag':
</span><span class="cx"> 
</span><span class="cx">         check_admin_referer( 'add-tag' );
</span></span></pre></div>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/edit.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -21,21 +21,25 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Handle bulk actions
</span><del>-if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) || isset($_REQUEST['bulk_edit']) ) {
</del><ins>+$doaction = $wp_list_table-&gt;current_action();
+
+if ( $doaction ) {
</ins><span class="cx">         check_admin_referer('bulk-posts');
</span><span class="cx">         $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
</span><span class="cx"> 
</span><span class="cx">         if ( strpos($sendback, 'post.php') !== false )
</span><span class="cx">                 $sendback = admin_url($post_new_file);
</span><span class="cx"> 
</span><del>-        if ( isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
-                $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
-                $post_ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( &quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_type=%s AND post_status = %s&quot;, $post_type, $post_status ) );
</del><ins>+        if ( 'delete_all' == $doaction ) {
+                $post_ids = $wpdb-&gt;get_col( &quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_type='attachment' AND post_status = 'trash'&quot; );
</ins><span class="cx">                 $doaction = 'delete';
</span><del>-        } elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) &amp;&amp; ( isset($_REQUEST['post']) || isset($_REQUEST['ids']) ) ) {
-                $post_ids = isset($_REQUEST['post']) ? array_map( 'intval', (array) $_REQUEST['post'] ) : explode(',', $_REQUEST['ids']);
-                $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
-        } else {
</del><ins>+        } elseif ( isset( $_REQUEST['media'] ) ) {
+                $post_ids = $_REQUEST['media'];
+        } elseif ( isset( $_REQUEST['ids'] ) ) {
+                $post_ids = explode( ',', $_REQUEST['ids'] );
+        }
+
+        if ( !isset( $post_ids ) ) {
</ins><span class="cx">                 wp_redirect( admin_url(&quot;edit.php?post_type=$post_type&quot;) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -97,8 +101,7 @@
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( isset($_REQUEST['action']) )
-                $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view'), $sendback );
</del><ins>+        $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view'), $sendback );
</ins><span class="cx"> 
</span><span class="cx">         wp_redirect($sendback);
</span><span class="cx">         exit();
</span></span></pre></div>
<a id="trunkwpadminincludesdefaultlisttablesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/default-list-tables.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/default-list-tables.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/includes/default-list-tables.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -215,6 +215,13 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function current_action() {
+                if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
+                        return 'delete_all';
+
+                return parent::current_action();
+        }
+
</ins><span class="cx">         function pagination( $which ) {
</span><span class="cx">                 global $post_type_object, $mode;
</span><span class="cx"> 
</span><span class="lines">@@ -1080,6 +1087,19 @@
</span><span class="cx"> &lt;?php
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function current_action() {
+                if ( isset( $_REQUEST['find_detached'] ) )
+                        return 'find_detached';
+
+                if ( isset( $_REQUEST['found_post_id'] ) &amp;&amp; isset( $_REQUEST['media'] ) )
+                        return 'attach';
+
+                if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
+                        return 'delete_all';
+
+                return parent::current_action();
+        }
+
</ins><span class="cx">         function has_items() {
</span><span class="cx">                 return have_posts();
</span><span class="cx">         }
</span><span class="lines">@@ -1482,6 +1502,13 @@
</span><span class="cx">                 return $actions;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function current_action() {
+                if ( isset( $_REQUEST['action'] ) &amp;&amp; isset( $_REQUEST['delete_tags'] ) &amp;&amp; ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
+                        return 'bulk-delete';
+
+                return parent::current_action();
+        }
+
</ins><span class="cx">         function get_columns() {
</span><span class="cx">                 global $taxonomy;
</span><span class="cx"> 
</span><span class="lines">@@ -1861,7 +1888,14 @@
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx">         }
</span><ins>+        
+        function current_action() {
+                if ( isset($_REQUEST['changeit']) &amp;&amp; !empty($_REQUEST['new_role']) )
+                        return 'promote';
</ins><span class="cx"> 
</span><ins>+                return parent::current_action();
+        }
+
</ins><span class="cx">         function get_columns() {
</span><span class="cx">                 return array(
</span><span class="cx">                         'cb'       =&gt; '&lt;input type=&quot;checkbox&quot; /&gt;',
</span><span class="lines">@@ -2214,6 +2248,13 @@
</span><span class="cx">                 echo '&lt;/div&gt;';
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function current_action() {
+                if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
+                        return 'delete_all';
+
+                return parent::current_action();
+        }
+
</ins><span class="cx">         function get_columns() {
</span><span class="cx">                 global $mode;
</span><span class="cx"> 
</span><span class="lines">@@ -3458,6 +3499,13 @@
</span><span class="cx">                 &lt;?php }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function current_action() {
+                if ( isset($_POST['clear-recent-list']) )
+                        return 'clear-recent-list';
+
+                return parent::current_action();
+        }
+
</ins><span class="cx">         function display_rows() {
</span><span class="cx">                 global $status, $page;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/list-table.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/list-table.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/includes/list-table.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -247,6 +247,24 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><ins>+         * Get the current action selected from the bulk actions dropdown.
+         *
+         * @since 3.1.0
+         * @access public
+         *
+         * @return string|bool The action name or False if no action was selected
+         */
+        function current_action() {
+                if ( isset( $_REQUEST['action'] ) &amp;&amp; -1 != $_REQUEST['action'] )
+                        return $_REQUEST['action'];
+
+                if ( isset( $_REQUEST['action2'] ) &amp;&amp; -1 != $_REQUEST['action2'] )
+                        return $_REQUEST['action2'];
+                
+                return false;
+        }
+
+        /**
</ins><span class="cx">          * Generate row actions div
</span><span class="cx">          *
</span><span class="cx">          * @since 3.1.0
</span></span></pre></div>
<a id="trunkwpadminlinkmanagerphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/link-manager.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/link-manager.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/link-manager.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -13,11 +13,11 @@
</span><span class="cx"> $wp_list_table-&gt;check_permissions();
</span><span class="cx"> 
</span><span class="cx"> // Handle bulk deletes
</span><del>-if ( isset( $_REQUEST['action'] ) &amp;&amp; isset( $_REQUEST['linkcheck'] ) ) {
</del><ins>+$doaction = $wp_list_table-&gt;current_action();
+
+if ( $doaction &amp;&amp; isset( $_REQUEST['linkcheck'] ) ) {
</ins><span class="cx">         check_admin_referer( 'bulk-bookmarks' );
</span><span class="cx"> 
</span><del>-        $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
-
</del><span class="cx">         if ( 'delete' == $doaction ) {
</span><span class="cx">                 $bulklinks = (array) $_REQUEST['linkcheck'];
</span><span class="cx">                 foreach ( $bulklinks as $link_id ) {
</span></span></pre></div>
<a id="trunkwpadminpluginsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugins.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugins.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/plugins.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -12,21 +12,14 @@
</span><span class="cx"> $wp_list_table = get_list_table('plugins');
</span><span class="cx"> $wp_list_table-&gt;check_permissions();
</span><span class="cx"> 
</span><del>-if ( isset($_POST['clear-recent-list']) )
-        $action = 'clear-recent-list';
-elseif ( !empty($_REQUEST['action']) )
-        $action = $_REQUEST['action'];
-elseif ( !empty($_REQUEST['action2']) )
-        $action = $_REQUEST['action2'];
-else
-        $action = false;
</del><ins>+$action = $wp_list_table-&gt;current_action();
</ins><span class="cx"> 
</span><span class="cx"> $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
</span><span class="cx"> 
</span><del>-//Clean up request URI from temporary args for screen options/paging uri's to work as expected.
</del><ins>+// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
</ins><span class="cx"> $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
</span><span class="cx"> 
</span><del>-if ( !empty($action) ) {
</del><ins>+if ( $action ) {
</ins><span class="cx">         $network_wide = false;
</span><span class="cx">         if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) &amp;&amp; is_multisite() &amp;&amp; current_user_can( 'manage_network_plugins' ) )
</span><span class="cx">                 $network_wide = true;
</span></span></pre></div>
<a id="trunkwpadminuploadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/upload.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/upload.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/upload.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -13,73 +13,18 @@
</span><span class="cx"> $wp_list_table-&gt;check_permissions();
</span><span class="cx"> 
</span><span class="cx"> // Handle bulk actions
</span><del>-if ( isset($_REQUEST['find_detached']) ) {
</del><ins>+$doaction = $wp_list_table-&gt;current_action();
+
+if ( $doaction ) {
</ins><span class="cx">         check_admin_referer('bulk-media');
</span><span class="cx"> 
</span><del>-        if ( !current_user_can('edit_posts') )
-                wp_die( __('You are not allowed to scan for lost attachments.') );
-
-        $lost = $wpdb-&gt;get_col( &quot;
-                SELECT ID FROM $wpdb-&gt;posts
-                WHERE post_type = 'attachment' AND post_parent &gt; '0'
-                AND post_parent NOT IN (
-                        SELECT ID FROM $wpdb-&gt;posts
-                        WHERE post_type NOT IN ( 'attachment', '&quot; . join( &quot;', '&quot;, get_post_types( array( 'public' =&gt; false ) ) ) . &quot;' )
-                )
-        &quot; );
-
-        $_REQUEST['detached'] = 1;
-
-} elseif ( isset( $_REQUEST['found_post_id'] ) &amp;&amp; isset( $_REQUEST['media'] ) ) {
-        check_admin_referer( 'bulk-media' );
-
-        $parent_id = (int) $_REQUEST['found_post_id'];
-        if ( !$parent_id )
-                return;
-
-        $parent = &amp;get_post( $parent_id );
-        if ( !current_user_can( 'edit_post', $parent_id ) )
-                wp_die( __( 'You are not allowed to edit this post.' ) );
-
-        $attach = array();
-        foreach ( (array) $_REQUEST['media'] as $att_id ) {
-                $att_id = (int) $att_id;
-
-                if ( !current_user_can( 'edit_post', $att_id ) )
-                        continue;
-
-                $attach[] = $att_id;
-                clean_attachment_cache( $att_id );
-        }
-
-        if ( ! empty( $attach ) ) {
-                $attach = implode( ',', $attach );
-                $attached = $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;UPDATE $wpdb-&gt;posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $attach )&quot;, $parent_id ) );
-        }
-
-        if ( isset( $attached ) ) {
-                $location = 'upload.php';
-                if ( $referer = wp_get_referer() ) {
-                        if ( false !== strpos( $referer, 'upload.php' ) )
-                                $location = $referer;
-                }
-
-                $location = add_query_arg( array( 'attached' =&gt; $attached ) , $location );
-                wp_redirect( $location );
-                exit;
-        }
-
-} elseif ( isset( $_REQUEST['doaction'] ) || isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
-        check_admin_referer( 'bulk-media' );
-
-        if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
</del><ins>+        if ( 'delete_all' == $doaction ) {
</ins><span class="cx">                 $post_ids = $wpdb-&gt;get_col( &quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_type='attachment' AND post_status = 'trash'&quot; );
</span><span class="cx">                 $doaction = 'delete';
</span><del>-        } elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) &amp;&amp; ( isset( $_REQUEST['media'] ) || isset( $_REQUEST['ids'] ) ) ) {
-                $post_ids = isset( $_REQUEST['media'] ) ? $_REQUEST['media'] : explode( ',', $_REQUEST['ids'] );
-                $doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
-        } else {
-                wp_redirect( $_SERVER['HTTP_REFERER'] );
</del><ins>+        } elseif ( isset( $_REQUEST['media'] ) ) {
+                $post_ids = $_REQUEST['media'];
+        } elseif ( isset( $_REQUEST['ids'] ) ) {
+                $post_ids = explode( ',', $_REQUEST['ids'] );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $location = 'upload.php';
</span><span class="lines">@@ -89,6 +34,58 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         switch ( $doaction ) {
</span><ins>+                case 'find_detached':
+                        if ( !current_user_can('edit_posts') )
+                                wp_die( __('You are not allowed to scan for lost attachments.') );
+
+                        $lost = $wpdb-&gt;get_col( &quot;
+                                SELECT ID FROM $wpdb-&gt;posts
+                                WHERE post_type = 'attachment' AND post_parent &gt; '0'
+                                AND post_parent NOT IN (
+                                        SELECT ID FROM $wpdb-&gt;posts
+                                        WHERE post_type NOT IN ( 'attachment', '&quot; . join( &quot;', '&quot;, get_post_types( array( 'public' =&gt; false ) ) ) . &quot;' )
+                                )
+                        &quot; );
+
+                        $_REQUEST['detached'] = 1;
+                        break;
+                case 'attach':
+                        $parent_id = (int) $_REQUEST['found_post_id'];
+                        if ( !$parent_id )
+                                return;
+
+                        $parent = &amp;get_post( $parent_id );
+                        if ( !current_user_can( 'edit_post', $parent_id ) )
+                                wp_die( __( 'You are not allowed to edit this post.' ) );
+
+                        $attach = array();
+                        foreach ( (array) $_REQUEST['media'] as $att_id ) {
+                                $att_id = (int) $att_id;
+
+                                if ( !current_user_can( 'edit_post', $att_id ) )
+                                        continue;
+
+                                $attach[] = $att_id;
+                                clean_attachment_cache( $att_id );
+                        }
+
+                        if ( ! empty( $attach ) ) {
+                                $attach = implode( ',', $attach );
+                                $attached = $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;UPDATE $wpdb-&gt;posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $attach )&quot;, $parent_id ) );
+                        }
+
+                        if ( isset( $attached ) ) {
+                                $location = 'upload.php';
+                                if ( $referer = wp_get_referer() ) {
+                                        if ( false !== strpos( $referer, 'upload.php' ) )
+                                                $location = $referer;
+                                }
+
+                                $location = add_query_arg( array( 'attached' =&gt; $attached ) , $location );
+                                wp_redirect( $location );
+                                exit;
+                        }
+                        break;
</ins><span class="cx">                 case 'trash':
</span><span class="cx">                         foreach ( (array) $post_ids as $post_id ) {
</span><span class="cx">                                 if ( !current_user_can( 'delete_post', $post_id ) )
</span></span></pre></div>
<a id="trunkwpadminusersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/users.php (15641 => 15642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/users.php        2010-09-21 19:41:35 UTC (rev 15641)
+++ trunk/wp-admin/users.php        2010-09-22 00:10:39 UTC (rev 15642)
</span><span class="lines">@@ -29,15 +29,6 @@
</span><span class="cx">     '&lt;p&gt;' . __('&lt;a href=&quot;http://wordpress.org/support/&quot; target=&quot;_blank&quot;&gt;Support Forums&lt;/a&gt;') . '&lt;/p&gt;'
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-$update = $doaction = '';
-if ( isset($_REQUEST['action']) )
-        $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
-
-if ( &quot;-1&quot; == $doaction ) {
-        if ( isset($_REQUEST['changeit']) &amp;&amp; !empty($_REQUEST['new_role']) )
-                $doaction = 'promote';
-}
-
</del><span class="cx"> if ( empty($_REQUEST) ) {
</span><span class="cx">         $referer = '&lt;input type=&quot;hidden&quot; name=&quot;wp_http_referer&quot; value=&quot;'. esc_attr(stripslashes($_SERVER['REQUEST_URI'])) . '&quot; /&gt;';
</span><span class="cx"> } elseif ( isset($_REQUEST['wp_http_referer']) ) {
</span><span class="lines">@@ -48,8 +39,10 @@
</span><span class="cx">         $referer = '';
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-switch ($doaction) {
</del><ins>+$update = '';
</ins><span class="cx"> 
</span><ins>+switch ( $wp_list_table-&gt;current_action() ) {
+
</ins><span class="cx"> /* Bulk Dropdown menu Role changes */
</span><span class="cx"> case 'promote':
</span><span class="cx">         check_admin_referer('bulk-users');
</span></span></pre>
</div>
</div>

</body>
</html>