diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 881dd5aef9..58ae29a43a 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -1450,7 +1450,7 @@ function _post_row($a_post, $pending_comments, $mode) {
$actions['inline hide-if-no-js'] = '' . __('Quick Edit') . '';
}
if ( current_user_can('delete_post', $post->ID) ) {
- $actions['trash'] = "ID) . "'>" . __('Trash') . "";
+ $actions['trash'] = "" . __('Trash') . "";
}
if ( in_array($post->post_status, array('pending', 'draft')) ) {
if ( current_user_can('edit_post', $post->ID) )
@@ -1670,7 +1670,7 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
$actions['inline'] = '' . __('Quick Edit') . '';
}
if ( current_user_can('delete_page', $page->ID) ) {
- $actions['trash'] = "ID) . "'>" . __('Trash') . "";
+ $actions['trash'] = "" . __('Trash') . "";
}
if ( in_array($post->post_status, array('pending', 'draft')) ) {
if ( current_user_can('edit_page', $page->ID) )
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 97a654b814..26c0281b35 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -731,6 +731,58 @@ function edit_post_link( $link = 'Edit This', $before = '', $after = '', $id = 0
echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
}
+/**
+ * Retrieve delete posts link for post.
+ *
+ * Can be used within the WordPress loop or outside of it. Can be used with
+ * pages, posts, attachments, and revisions.
+ *
+ * @since 2.9.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param string $context Optional, default to display. How to write the '&', defaults to '&'.
+ * @return string
+ */
+function get_delete_post_link($id = 0, $context = 'display') {
+ if ( !$post = &get_post( $id ) )
+ return;
+
+ if ( 'display' == $context )
+ $action = 'action=trash&';
+ else
+ $action = 'action=trash&';
+
+ 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;
+
+ return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url("$file.php?{$action}$var=$post->ID"), "trash-{$file}_" . $post->ID ), $context );
+}
+
/**
* Retrieve edit comment link.
*