[wp-trac] [WordPress Trac] #21194: Delete attachment AJAX fails when EMPTY_TRASH_DAYS is set to 0 days
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 20 21:00:55 UTC 2012
#21194: Delete attachment AJAX fails when EMPTY_TRASH_DAYS is set to 0 days
------------------------------+-----------------------
Reporter: simonwheatley | Owner:
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 3.5
Component: Media | Version: 2.0
Severity: normal | Resolution:
Keywords: has-patch commit |
------------------------------+-----------------------
Comment (by c3mdigital):
Replying to [comment:12 SergeyBiryukov]:
> [attachment:21194v4.patch] changes the class of the "Delete Permanently"
button. This would affect its styling (remove the red background on hover,
see [comment:ticket:21196:9]). Let's skip this UI change.
The reason I changed the class in the 21194v4.patch is because
class="delete" binds it to the "trash-post" ajax action in handlers.js.
{{{
jQuery('a.delete', item).click(function(){
// Tell the server to delete it. TODO: handle exceptions
jQuery.ajax({
url: ajaxurl,
type: 'post',
success: deleteSuccess,
error: deleteError,
id: fileObj.id,
data: {
id : this.id.replace(/[^0-9]/g, ''),
action : 'trash-post',
_ajax_nonce :
this.href.replace(/^.*wpnonce=/,'')
}
});
return false;
});
}}}
This causes the nonce check to fail and never runs the delete.
{{{
function wp_ajax_trash_post( $action ) {
if ( empty( $action ) )
$action = 'trash-post';
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "{$action}_$id" );
if ( !current_user_can( 'delete_post', $id ) )
wp_die( -1 );
if ( !get_post( $id ) )
wp_die( 1 );
if ( 'trash-post' == $action )
$done = wp_trash_post( $id );
else
$done = wp_untrash_post( $id );
if ( $done )
wp_die( 1 );
wp_die( 0 );
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21194#comment:14>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list