<!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"> </script>
</span><span class="cx"> <?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("edit.php?post_type=$post_type") );
</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']) && (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 ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
</del><ins>+        echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
</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->publish );
</span><span class="cx">         $text = _n( 'Page', 'Pages', $num_pages->publish );
</span><span class="cx">         if ( current_user_can( 'edit_pages' ) ) {
</span><del>-                $num = "<a href='edit-pages.php'>$num</a>";
-                $text = "<a href='edit-pages.php'>$text</a>";
</del><ins>+                $num = "<a href='edit.php?post_type=page'>$num</a>";
+                $text = "<a href='edit.php?post_type=page'>$text</a>";
</ins><span class="cx">         }
</span><span class="cx">         echo '<td class="first b b_pages">' . $num . '</td>';
</span><span class="cx">         echo '<td class="t pages">' . $text . '</td>';
</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->post_type;
</ins><span class="cx"> ?>
</span><span class="cx"> <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
</span><span class="cx"> <?php
</span><span class="lines">@@ -1669,11 +1670,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 if ( current_user_can('delete_page', $page->ID) ) {
</span><span class="cx">                         if ( $post->post_status == 'trash' )
</span><del>-                                $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=untrash&amp;post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>";
</del><ins>+                                $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&amp;action=untrash&amp;post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>";
</ins><span class="cx">                         elseif ( EMPTY_TRASH_DAYS )
</span><span class="cx">                                 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>";
</span><span class="cx">                         if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS )
</span><del>-                                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
</del><ins>+                                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&amp;action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
</ins><span class="cx">                 }
</span><span class="cx">                 if ( in_array($post->post_status, array('pending', 'draft')) ) {
</span><span class="cx">                         if ( current_user_can('edit_page', $page->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&';
</span><span class="cx">
</span><del>-        switch ( $post->post_type ) :
-        case 'page' :
-                if ( !current_user_can( 'delete_page', $post->ID ) )
-                        return;
-                $file = 'page';
-                $var = 'post';
-                break;
-        case 'attachment' :
-                if ( !current_user_can( 'delete_post', $post->ID ) )
-                        return;
-                $file = 'media';
-                $var = 'attachment_id';
-                break;
-        case 'revision' :
-                if ( !current_user_can( 'delete_post', $post->ID ) )
-                        return;
-                $file = 'revision';
-                $var = 'revision';
-                $action = '';
-                break;
-        default :
-                if ( !current_user_can( 'edit_post', $post->ID ) )
-                        return apply_filters( 'get_delete_post_link', '', $post->ID, $context );
-                $file = 'post';
-                $var = 'post';
-                break;
-        endswitch;
</del><ins>+        if ( 'display' == $context )
+                $action = '&amp;action=trash';
+        else
+                $action = '&action=trash';
</ins><span class="cx">
</span><del>-        return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url("$file.php?{$action}$var=$post->ID"), "trash-{$file}_" . $post->ID ), $context );
</del><ins>+        $post_type_object = get_post_type_object( $post->post_type );
+        if ( !$post_type_object )
+                return;
+
+        if ( !current_user_can( $post_type_object->delete_cap, $post->ID ) )
+                return;
+
+        return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), "trash-{$post->post_type}_" . $post->ID), $post->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->capability_type) ) {
</span><span class="cx">                 $args->edit_cap = '';
</span><span class="cx">                 $args->read_cap = '';
</span><ins>+                $args->delete_cap = '';
</ins><span class="cx">         } else {
</span><span class="cx">                 $args->edit_cap = 'edit_' . $args->capability_type;
</span><span class="cx">                 $args->read_cap = 'read_' . $args->capability_type;
</span><ins>+                $args->delete_cap = 'delete_' . $args->capability_type;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ( !$args->_builtin && $args->public )
</span></span></pre>
</div>
</div>
</body>
</html>