WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/22/2010 12:10:39 AM (10 years ago)
Author:
scribu
Message:

Introduce WP_List_Table::current_action() and use throughout admin list screens. See #14579

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit.php

    r15578 r15642  
    2222
    2323// Handle bulk actions
    24 if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) || isset($_REQUEST['bulk_edit']) ) {
     24$doaction = $wp_list_table->current_action();
     25
     26if ( $doaction ) {
    2527    check_admin_referer('bulk-posts');
    2628    $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
     
    2931        $sendback = admin_url($post_new_file);
    3032
    31     if ( isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
    32         $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
    33         $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
     33    if ( 'delete_all' == $doaction ) {
     34        $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
    3435        $doaction = 'delete';
    35     } elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && ( isset($_REQUEST['post']) || isset($_REQUEST['ids']) ) ) {
    36         $post_ids = isset($_REQUEST['post']) ? array_map( 'intval', (array) $_REQUEST['post'] ) : explode(',', $_REQUEST['ids']);
    37         $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
    38     } else {
     36    } elseif ( isset( $_REQUEST['media'] ) ) {
     37        $post_ids = $_REQUEST['media'];
     38    } elseif ( isset( $_REQUEST['ids'] ) ) {
     39        $post_ids = explode( ',', $_REQUEST['ids'] );
     40    }
     41
     42    if ( !isset( $post_ids ) ) {
    3943        wp_redirect( admin_url("edit.php?post_type=$post_type") );
    4044    }
     
    98102    }
    99103
    100     if ( isset($_REQUEST['action']) )
    101         $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view'), $sendback );
     104    $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view'), $sendback );
    102105
    103106    wp_redirect($sendback);
Note: See TracChangeset for help on using the changeset viewer.