Ticket #12708: get_delete_post_link.2.diff

File get_delete_post_link.2.diff, 4.2 KB (added by scribu, 3 years ago)

deprecate $context arg

  • wp-includes/link-template.php

     
    821821/** 
    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 '&'. 
     829 * @param string $deprecated Not used. 
     830 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. 
    831831 * @return string 
    832832 */ 
    833 function get_delete_post_link($id = 0, $context = 'display') { 
     833function get_delete_post_link($id = 0, $deprecated = '', $force_delete = false) { 
     834        if ( !empty( $deprecated ) ) 
     835                _deprecated_argument( __FUNCTION__, '3.0' ); 
     836 
    834837        if ( !$post = &get_post( $id ) ) 
    835838                return; 
    836839 
    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'; 
    846  
    847840        $post_type_object = get_post_type_object( $post->post_type ); 
    848841        if ( !$post_type_object ) 
    849842                return; 
     
    851844        if ( !current_user_can( $post_type_object->delete_cap, $post->ID ) ) 
    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        if ( $force_delete || !EMPTY_TRASH_DAYS ) 
     848                $action = 'delete'; 
     849        else 
     850                $action = 'trash'; 
     851 
     852        $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); 
     853 
     854        return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-{$post->post_type}_{$post->ID}" ), $post->ID ); 
    855855} 
    856856 
    857857/** 
  • wp-admin/includes/meta-boxes.php

     
    194194<div id="delete-action"> 
    195195<?php 
    196196if ( current_user_can( "delete_post", $post->ID ) ) { 
    197         if ( !EMPTY_TRASH_DAYS ) { 
    198                 $delete_url = wp_nonce_url( add_query_arg( array('action' => 'delete', 'post' => $post->ID), admin_url( 'post.php' ) ), "delete-${post_type}_{$post->ID}" ); 
     197        if ( !EMPTY_TRASH_DAYS ) 
    199198                $delete_text = __('Delete Permanently'); 
    200         } else { 
    201                 $delete_url = wp_nonce_url( add_query_arg( array('action' => 'trash', 'post' => $post->ID), admin_url( 'post.php' ) ), "trash-${post_type}_{$post->ID}" ); 
     199        else 
    202200                $delete_text = __('Move to Trash'); 
    203         } ?> 
    204 <a class="submitdelete deletion" href="<?php echo $delete_url; ?>"><?php echo $delete_text; ?></a><?php 
     201        ?> 
     202<a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php 
    205203} ?> 
    206204</div> 
    207205 
  • wp-admin/includes/template.php

     
    13591359                                elseif ( EMPTY_TRASH_DAYS ) 
    13601360                                        $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>"; 
    13611361                                if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) 
    1362                                         $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>"; 
     1362                                        $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>"; 
    13631363                        } 
    13641364                        if ( in_array($post->post_status, array('pending', 'draft')) ) { 
    13651365                                if ( current_user_can($post_type_object->edit_cap, $post->ID) )