Add $force_delete to get_delete_post_link(). Remove unnecessary argument. props scribu, fixes #12708
git-svn-id: http://svn.automattic.com/wordpress/trunk@14099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7b83161397
commit
c4abc1c875
|
@ -194,14 +194,12 @@ if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
|
|||
<div id="delete-action">
|
||||
<?php
|
||||
if ( current_user_can( "delete_post", $post->ID ) ) {
|
||||
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}" );
|
||||
if ( !EMPTY_TRASH_DAYS )
|
||||
$delete_text = __('Delete Permanently');
|
||||
} else {
|
||||
$delete_url = wp_nonce_url( add_query_arg( array('action' => 'trash', 'post' => $post->ID), admin_url( 'post.php' ) ), "trash-${post_type}_{$post->ID}" );
|
||||
else
|
||||
$delete_text = __('Move to Trash');
|
||||
} ?>
|
||||
<a class="submitdelete deletion" href="<?php echo $delete_url; ?>"><?php echo $delete_text; ?></a><?php
|
||||
?>
|
||||
<a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1359,7 +1359,7 @@ function _post_row($a_post, $pending_comments, $mode) {
|
|||
elseif ( EMPTY_TRASH_DAYS )
|
||||
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
|
||||
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . '&action=delete', $post->ID) ), 'delete-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Delete Permanently') . "</a>";
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
|
||||
}
|
||||
if ( in_array($post->post_status, array('pending', 'draft')) ) {
|
||||
if ( current_user_can($post_type_object->edit_cap, $post->ID) )
|
||||
|
|
|
@ -821,29 +821,22 @@ function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
|
|||
/**
|
||||
* 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.
|
||||
* Can be used within the WordPress loop or outside of it, with any post type.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param int $id Optional. Post ID.
|
||||
* @param string $context Optional, default to display. How to write the '&', defaults to '&'.
|
||||
* @param string $deprecated Not used.
|
||||
* @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
|
||||
* @return string
|
||||
*/
|
||||
function get_delete_post_link($id = 0, $context = 'display') {
|
||||
function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
|
||||
if ( ! empty( $deprecated ) )
|
||||
_deprecated_argument( __FUNCTION__, '3.0.0' );
|
||||
|
||||
if ( !$post = &get_post( $id ) )
|
||||
return;
|
||||
|
||||
if ( 'display' == $context )
|
||||
$action = 'action=trash&';
|
||||
else
|
||||
$action = 'action=trash&';
|
||||
|
||||
if ( 'display' == $context )
|
||||
$action = '&action=trash';
|
||||
else
|
||||
$action = '&action=trash';
|
||||
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
if ( !$post_type_object )
|
||||
return;
|
||||
|
@ -851,7 +844,11 @@ function get_delete_post_link($id = 0, $context = 'display') {
|
|||
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 );
|
||||
$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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue