Ticket #21194: 21194v3.patch

File 21194v3.patch, 2.1 KB (added by c3mdigital, 11 months ago)
  • wp-admin/includes/ajax-actions.php

     
    475475} 
    476476 
    477477function wp_ajax_trash_post( $action ) { 
    478         if ( empty( $action ) ) 
     478        $id = isset( $_POST['id'] ) ? (int)$_POST['id'] : 0; 
     479        if ( empty( $action ) && 'attachment' == get_post_type( $id ) ) 
     480                $action = 'trash-attachment'; 
     481        elseif ( empty( $action ) ) 
    479482                $action = 'trash-post'; 
    480         $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 
    481483 
    482484        check_ajax_referer( "{$action}_$id" ); 
    483485        if ( !current_user_can( 'delete_post', $id ) ) 
     
    486488        if ( !get_post( $id ) ) 
    487489                wp_die( 1 ); 
    488490 
    489         if ( 'trash-post' == $action ) 
     491        if ( 'trash-post' == $action || 'trash-attachment' == $action ) 
    490492                $done = wp_trash_post( $id ); 
    491493        else 
    492494                $done = wp_untrash_post( $id ); 
  • wp-admin/includes/media.php

     
    11591159        if ( $send ) 
    11601160                $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); 
    11611161        if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { 
    1162                 if ( !EMPTY_TRASH_DAYS ) { 
    1163                         $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>'; 
    1164                 } elseif ( !MEDIA_TRASH ) { 
     1162                if ( !MEDIA_TRASH ) { 
    11651163                        $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 
    11661164                         <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p> 
    11671165                         <a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a>