<!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>[14099] trunk: Add $force_delete to get_delete_post_link().</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14099">14099</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-04-16 02:29:10 +0000 (Fri, 16 Apr 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add $force_delete to get_delete_post_link(). Remove unnecessary argument. props scribu, fixes <a href="http://trac.wordpress.org/ticket/12708">#12708</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmetaboxesphp">trunk/wp-admin/includes/meta-boxes.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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/meta-boxes.php (14098 => 14099)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/meta-boxes.php        2010-04-16 02:08:28 UTC (rev 14098)
+++ trunk/wp-admin/includes/meta-boxes.php        2010-04-16 02:29:10 UTC (rev 14099)
</span><span class="lines">@@ -194,14 +194,12 @@
</span><span class="cx"> <div id="delete-action">
</span><span class="cx"> <?php
</span><span class="cx"> if ( current_user_can( "delete_post", $post->ID ) ) {
</span><del>-        if ( !EMPTY_TRASH_DAYS ) {
-                $delete_url = wp_nonce_url( add_query_arg( array('action' => 'delete', 'post' => $post->ID), admin_url( 'post.php' ) ), "delete-${post_type}_{$post->ID}" );
</del><ins>+        if ( !EMPTY_TRASH_DAYS )
</ins><span class="cx">                 $delete_text = __('Delete Permanently');
</span><del>-        } else {
-                $delete_url = wp_nonce_url( add_query_arg( array('action' => 'trash', 'post' => $post->ID), admin_url( 'post.php' ) ), "trash-${post_type}_{$post->ID}" );
</del><ins>+        else
</ins><span class="cx">                 $delete_text = __('Move to Trash');
</span><del>-        } ?>
-<a class="submitdelete deletion" href="<?php echo $delete_url; ?>"><?php echo $delete_text; ?></a><?php
</del><ins>+        ?>
+<a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
</ins><span class="cx"> } ?>
</span><span class="cx"> </div>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (14098 => 14099)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-04-16 02:08:28 UTC (rev 14098)
+++ trunk/wp-admin/includes/template.php        2010-04-16 02:29:10 UTC (rev 14099)
</span><span class="lines">@@ -1359,7 +1359,7 @@
</span><span class="cx">                                 elseif ( EMPTY_TRASH_DAYS )
</span><span class="cx">                                         $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
</span><span class="cx">                                 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
</span><del>-                                        $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . '&amp;action=delete', $post->ID) ), 'delete-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Delete Permanently') . "</a>";
</del><ins>+                                        $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('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($post_type_object->edit_cap, $post->ID) )
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (14098 => 14099)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2010-04-16 02:08:28 UTC (rev 14098)
+++ trunk/wp-includes/link-template.php        2010-04-16 02:29:10 UTC (rev 14099)
</span><span class="lines">@@ -821,29 +821,22 @@
</span><span class="cx"> /**
</span><span class="cx"> * Retrieve delete posts link for post.
</span><span class="cx"> *
</span><del>- * Can be used within the WordPress loop or outside of it. Can be used with
- * pages, posts, attachments, and revisions.
</del><ins>+ * Can be used within the WordPress loop or outside of it, with any post type.
</ins><span class="cx"> *
</span><span class="cx"> * @since 2.9.0
</span><span class="cx"> *
</span><span class="cx"> * @param int $id Optional. Post ID.
</span><del>- * @param string $context Optional, default to display. How to write the '&', defaults to '&amp;'.
</del><ins>+ * @param string $deprecated Not used.
+ * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><del>-function get_delete_post_link($id = 0, $context = 'display') {
</del><ins>+function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
+        if ( ! empty( $deprecated ) )
+                _deprecated_argument( __FUNCTION__, '3.0.0' );
+
</ins><span class="cx">         if ( !$post = &get_post( $id ) )
</span><span class="cx">                 return;
</span><span class="cx">
</span><del>-        if ( 'display' == $context )
-                $action = 'action=trash&amp;';
-        else
-                $action = 'action=trash&';
-
-        if ( 'display' == $context )
-                $action = '&amp;action=trash';
-        else
-                $action = '&action=trash';
-
</del><span class="cx">         $post_type_object = get_post_type_object( $post->post_type );
</span><span class="cx">         if ( !$post_type_object )
</span><span class="cx">                 return;
</span><span class="lines">@@ -851,7 +844,11 @@
</span><span class="cx">         if ( !current_user_can( $post_type_object->delete_cap, $post->ID ) )
</span><span class="cx">                 return;
</span><span class="cx">
</span><del>-        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 );
</del><ins>+        $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
+
+        $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
+
+        return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-{$post->post_type}_{$post->ID}" ), $post->ID, $force_delete );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>
</body>
</html>