Partially revert [15642]. Fixes Bulk deletion of non-media items. As a bonus, exit on redirects & check the post status is valid before querying it. See #14579

git-svn-id: http://svn.automattic.com/wordpress/trunk@15667 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-09-26 10:56:36 +00:00
parent 2ed8e66a7c
commit deb8828381
1 changed files with 6 additions and 1 deletions

View File

@ -31,16 +31,21 @@ if ( $doaction ) {
$sendback = admin_url($post_new_file);
if ( 'delete_all' == $doaction ) {
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
if ( get_post_status_object($post_status) ) // Check the post status exists first
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
$doaction = 'delete';
} elseif ( isset( $_REQUEST['media'] ) ) {
$post_ids = $_REQUEST['media'];
} elseif ( isset( $_REQUEST['ids'] ) ) {
$post_ids = explode( ',', $_REQUEST['ids'] );
} elseif ( !empty( $_REQUEST['post'] ) ) {
$post_ids = array_map('intval', $_REQUEST['post']);
}
if ( !isset( $post_ids ) ) {
wp_redirect( admin_url("edit.php?post_type=$post_type") );
exit;
}
switch ( $doaction ) {