<!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>[12783] trunk: Update trash and right now links for pages.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12783">12783</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-01-21 06:53:33 +0000 (Thu, 21 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update trash and right now links for pages. fixes <a href="http://trac.wordpress.org/ticket/11958">#11958</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminheaderphp">trunk/wp-admin/admin-header.php</a></li>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.php</a></li>
<li><a href="#trunkwpadminincludesdashboardphp">trunk/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-header.php (12782 => 12783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-header.php        2010-01-20 23:01:09 UTC (rev 12782)
+++ trunk/wp-admin/admin-header.php        2010-01-21 06:53:33 UTC (rev 12783)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><del>-if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php') ) ) {
</del><ins>+if ( in_array( $pagenow, array('post.php', 'post-new.php') ) ) {
</ins><span class="cx">         add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
</span><span class="cx">         wp_enqueue_script('quicktags');
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (12782 => 12783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2010-01-20 23:01:09 UTC (rev 12782)
+++ trunk/wp-admin/edit.php        2010-01-21 06:53:33 UTC (rev 12783)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">                 $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
</span><span class="cx">                 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
</span><span class="cx">         } else {
</span><del>-                wp_redirect( admin_url('edit.php') );
</del><ins>+                wp_redirect( admin_url(&quot;edit.php?post_type=$post_type&quot;) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         switch ( $doaction ) {
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( isset($_GET['action']) )
</span><del>-                $sendback = remove_query_arg( array('action', 'action2', 'cat', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view', 'post_type'), $sendback );
</del><ins>+                $sendback = remove_query_arg( array('action', 'action2', 'cat', '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 class="lines">@@ -198,7 +198,7 @@
</span><span class="cx"> if ( isset($_GET['trashed']) &amp;&amp; (int) $_GET['trashed'] ) {
</span><span class="cx">         printf( _n( 'Item moved to the trash.', '%s items moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
</span><span class="cx">         $ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
</span><del>-        echo ' &lt;a href=&quot;' . esc_url( wp_nonce_url( &quot;edit.php?doaction=undo&amp;action=untrash&amp;ids=$ids&quot;, &quot;bulk-posts&quot; ) ) . '&quot;&gt;' . __('Undo') . '&lt;/a&gt;&lt;br /&gt;';
</del><ins>+        echo ' &lt;a href=&quot;' . esc_url( wp_nonce_url( &quot;edit.php?post_type=$post_type&amp;doaction=undo&amp;action=untrash&amp;ids=$ids&quot;, &quot;bulk-posts&quot; ) ) . '&quot;&gt;' . __('Undo') . '&lt;/a&gt;&lt;br /&gt;';
</ins><span class="cx">         unset($_GET['trashed']);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludesdashboardphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/dashboard.php (12782 => 12783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/dashboard.php        2010-01-20 23:01:09 UTC (rev 12782)
+++ trunk/wp-admin/includes/dashboard.php        2010-01-21 06:53:33 UTC (rev 12783)
</span><span class="lines">@@ -252,8 +252,8 @@
</span><span class="cx">         $num = number_format_i18n( $num_pages-&gt;publish );
</span><span class="cx">         $text = _n( 'Page', 'Pages', $num_pages-&gt;publish );
</span><span class="cx">         if ( current_user_can( 'edit_pages' ) ) {
</span><del>-                $num = &quot;&lt;a href='edit-pages.php'&gt;$num&lt;/a&gt;&quot;;
-                $text = &quot;&lt;a href='edit-pages.php'&gt;$text&lt;/a&gt;&quot;;
</del><ins>+                $num = &quot;&lt;a href='edit.php?post_type=page'&gt;$num&lt;/a&gt;&quot;;
+                $text = &quot;&lt;a href='edit.php?post_type=page'&gt;$text&lt;/a&gt;&quot;;
</ins><span class="cx">         }
</span><span class="cx">         echo '&lt;td class=&quot;first b b_pages&quot;&gt;' . $num . '&lt;/td&gt;';
</span><span class="cx">         echo '&lt;td class=&quot;t pages&quot;&gt;' . $text . '&lt;/td&gt;';
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (12782 => 12783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-01-20 23:01:09 UTC (rev 12782)
+++ trunk/wp-admin/includes/template.php        2010-01-21 06:53:33 UTC (rev 12783)
</span><span class="lines">@@ -1605,6 +1605,7 @@
</span><span class="cx">         $posts_columns = get_column_headers( $current_screen );
</span><span class="cx">         $hidden = get_hidden_columns(  $current_screen );
</span><span class="cx">         $title = _draft_or_post_title();
</span><ins>+        $post_type = $page-&gt;post_type;
</ins><span class="cx"> ?&gt;
</span><span class="cx"> &lt;tr id=&quot;page-&lt;?php echo $id; ?&gt;&quot; class=&quot;&lt;?php echo $rowclass; ?&gt; iedit&quot;&gt;
</span><span class="cx"> &lt;?php
</span><span class="lines">@@ -1669,11 +1670,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 if ( current_user_can('delete_page', $page-&gt;ID) ) {
</span><span class="cx">                         if ( $post-&gt;post_status == 'trash' )
</span><del>-                                $actions['untrash'] = &quot;&lt;a title='&quot; . esc_attr(__('Remove this page from the Trash')) . &quot;' href='&quot; . wp_nonce_url(&quot;page.php?action=untrash&amp;amp;post=$page-&gt;ID&quot;, 'untrash-page_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Restore') . &quot;&lt;/a&gt;&quot;;
</del><ins>+                                $actions['untrash'] = &quot;&lt;a title='&quot; . esc_attr(__('Remove this page from the Trash')) . &quot;' href='&quot; . wp_nonce_url(&quot;post.php?post_type=$post_type&amp;amp;action=untrash&amp;amp;post=$page-&gt;ID&quot;, 'untrash-page_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Restore') . &quot;&lt;/a&gt;&quot;;
</ins><span class="cx">                         elseif ( EMPTY_TRASH_DAYS )
</span><span class="cx">                                 $actions['trash'] = &quot;&lt;a class='submitdelete' title='&quot; . esc_attr(__('Move this page to the Trash')) . &quot;' href='&quot; . get_delete_post_link($page-&gt;ID) . &quot;'&gt;&quot; . __('Trash') . &quot;&lt;/a&gt;&quot;;
</span><span class="cx">                         if ( $post-&gt;post_status == 'trash' || !EMPTY_TRASH_DAYS )
</span><del>-                                $actions['delete'] = &quot;&lt;a class='submitdelete' title='&quot; . esc_attr(__('Delete this page permanently')) . &quot;' href='&quot; . wp_nonce_url(&quot;page.php?action=delete&amp;amp;post=$page-&gt;ID&quot;, 'delete-page_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Delete Permanently') . &quot;&lt;/a&gt;&quot;;
</del><ins>+                                $actions['delete'] = &quot;&lt;a class='submitdelete' title='&quot; . esc_attr(__('Delete this page permanently')) . &quot;' href='&quot; . wp_nonce_url(&quot;post.php?post_type=$post_type&amp;amp;action=delete&amp;amp;post=$page-&gt;ID&quot;, 'delete-page_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Delete Permanently') . &quot;&lt;/a&gt;&quot;;
</ins><span class="cx">                 }
</span><span class="cx">                 if ( in_array($post-&gt;post_status, array('pending', 'draft')) ) {
</span><span class="cx">                         if ( current_user_can('edit_page', $page-&gt;ID) )
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (12782 => 12783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2010-01-20 23:01:09 UTC (rev 12782)
+++ trunk/wp-includes/link-template.php        2010-01-21 06:53:33 UTC (rev 12783)
</span><span class="lines">@@ -737,35 +737,19 @@
</span><span class="cx">         else
</span><span class="cx">                 $action = 'action=trash&amp;';
</span><span class="cx"> 
</span><del>-        switch ( $post-&gt;post_type ) :
-        case 'page' :
-                if ( !current_user_can( 'delete_page', $post-&gt;ID ) )
-                        return;
-                $file = 'page';
-                $var  = 'post';
-                break;
-        case 'attachment' :
-                if ( !current_user_can( 'delete_post', $post-&gt;ID ) )
-                        return;
-                $file = 'media';
-                $var  = 'attachment_id';
-                break;
-        case 'revision' :
-                if ( !current_user_can( 'delete_post', $post-&gt;ID ) )
-                        return;
-                $file = 'revision';
-                $var  = 'revision';
-                $action = '';
-                break;
-        default :
-                if ( !current_user_can( 'edit_post', $post-&gt;ID ) )
-                        return apply_filters( 'get_delete_post_link', '', $post-&gt;ID, $context );
-                $file = 'post';
-                $var  = 'post';
-                break;
-        endswitch;
</del><ins>+        if ( 'display' == $context )
+                $action = '&amp;amp;action=trash';
+        else
+                $action = '&amp;action=trash';
</ins><span class="cx"> 
</span><del>-        return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url(&quot;$file.php?{$action}$var=$post-&gt;ID&quot;), &quot;trash-{$file}_&quot; . $post-&gt;ID ), $context );
</del><ins>+        $post_type_object = get_post_type_object( $post-&gt;post_type );
+        if ( !$post_type_object )
+                return;
+
+        if ( !current_user_can( $post_type_object-&gt;delete_cap, $post-&gt;ID ) )
+                return;
+
+        return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url( sprintf($post_type_object-&gt;_edit_link . $action, $post-&gt;ID) ),  &quot;trash-{$post-&gt;post_type}_&quot; . $post-&gt;ID), $post-&gt;ID, $context );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (12782 => 12783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-01-20 23:01:09 UTC (rev 12782)
+++ trunk/wp-includes/post.php        2010-01-21 06:53:33 UTC (rev 12783)
</span><span class="lines">@@ -720,9 +720,11 @@
</span><span class="cx">         if ( empty($args-&gt;capability_type) ) {
</span><span class="cx">                 $args-&gt;edit_cap = '';
</span><span class="cx">                 $args-&gt;read_cap = '';
</span><ins>+                $args-&gt;delete_cap = '';
</ins><span class="cx">         } else {
</span><span class="cx">                 $args-&gt;edit_cap = 'edit_' . $args-&gt;capability_type;
</span><span class="cx">                 $args-&gt;read_cap = 'read_' . $args-&gt;capability_type;
</span><ins>+                $args-&gt;delete_cap = 'delete_' . $args-&gt;capability_type;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( !$args-&gt;_builtin &amp;&amp; $args-&gt;public )
</span></span></pre>
</div>
</div>

</body>
</html>