WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/16/2010 02:29:10 AM (12 years ago)
Author:
nacin
Message:

Add $force_delete to get_delete_post_link(). Remove unnecessary argument. props scribu, fixes #12708

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r14068 r14099  
    822822 * Retrieve delete posts link for post.
    823823 *
    824  * Can be used within the WordPress loop or outside of it. Can be used with
    825  * pages, posts, attachments, and revisions.
     824 * Can be used within the WordPress loop or outside of it, with any post type.
    826825 *
    827826 * @since 2.9.0
    828827 *
    829828 * @param int $id Optional. Post ID.
    830  * @param string $context Optional, default to display. How to write the '&', defaults to '&'.
    831  * @return string
    832  */
    833 function get_delete_post_link($id = 0, $context = 'display') {
     829 * @param string $deprecated Not used.
     830 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
     831 * @return string
     832 */
     833function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
     834    if ( ! empty( $deprecated ) )
     835        _deprecated_argument( __FUNCTION__, '3.0.0' );
     836
    834837    if ( !$post = &get_post( $id ) )
    835838        return;
    836 
    837     if ( 'display' == $context )
    838         $action = 'action=trash&';
    839     else
    840         $action = 'action=trash&';
    841 
    842     if ( 'display' == $context )
    843         $action = '&action=trash';
    844     else
    845         $action = '&action=trash';
    846839
    847840    $post_type_object = get_post_type_object( $post->post_type );
     
    852845        return;
    853846
    854     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 );
     847    $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
     848
     849    $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
     850
     851    return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-{$post->post_type}_{$post->ID}" ), $post->ID, $force_delete );
    855852}
    856853
Note: See TracChangeset for help on using the changeset viewer.