Make WordPress Core


Ignore:
Timestamp:
01/13/2011 12:50:35 AM (13 years ago)
Author:
nacin
Message:

Revert [17275] and [17276]. The rabbit hole is too deep. see #16166.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-posts-list-table.php

    r17276 r17277  
    10141014<?php
    10151015    }
    1016 
    1017     function do_bulk_actions( $doaction = null ) {
    1018         if ( null === $doaction )
    1019             $doaction = $this->current_action();
    1020 
    1021         if ( ! $doaction )
    1022             return;
    1023 
    1024         check_admin_referer('bulk-posts');
    1025 
    1026         $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
    1027         if ( strpos($sendback, 'post.php') !== false )
    1028             $sendback = admin_url($post_new_file);
    1029 
    1030         if ( 'delete_all' == $doaction ) {
    1031             $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
    1032             if ( get_post_status_object($post_status) ) // Check the post status exists first
    1033                 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
    1034             $doaction = 'delete';
    1035         } elseif ( isset( $_REQUEST['media'] ) ) {
    1036             $post_ids = $_REQUEST['media'];
    1037         } elseif ( isset( $_REQUEST['ids'] ) ) {
    1038             $post_ids = explode( ',', $_REQUEST['ids'] );
    1039         } elseif ( !empty( $_REQUEST['post'] ) ) {
    1040             $post_ids = array_map('intval', $_REQUEST['post']);
    1041         }
    1042 
    1043         if ( !isset( $post_ids ) ) {
    1044             wp_redirect( admin_url("edit.php?post_type=$post_type") );
    1045             exit;
    1046         }
    1047 
    1048         switch ( $doaction ) {
    1049             case 'trash':
    1050                 $trashed = 0;
    1051                 foreach( (array) $post_ids as $post_id ) {
    1052                     if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    1053                         wp_die( __('You are not allowed to move this item to the Trash.') );
    1054 
    1055                     if ( !wp_trash_post($post_id) )
    1056                         wp_die( __('Error in moving to Trash.') );
    1057 
    1058                     $trashed++;
    1059                 }
    1060                 $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids) ), $sendback );
    1061                 break;
    1062             case 'untrash':
    1063                 $untrashed = 0;
    1064                 foreach( (array) $post_ids as $post_id ) {
    1065                     if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    1066                         wp_die( __('You are not allowed to restore this item from the Trash.') );
    1067 
    1068                     if ( !wp_untrash_post($post_id) )
    1069                         wp_die( __('Error in restoring from Trash.') );
    1070 
    1071                     $untrashed++;
    1072                 }
    1073                 $sendback = add_query_arg('untrashed', $untrashed, $sendback);
    1074                 break;
    1075             case 'delete':
    1076                 $deleted = 0;
    1077                 foreach( (array) $post_ids as $post_id ) {
    1078                     $post_del = & get_post($post_id);
    1079 
    1080                     if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    1081                         wp_die( __('You are not allowed to delete this item.') );
    1082 
    1083                     if ( $post_del->post_type == 'attachment' ) {
    1084                         if ( ! wp_delete_attachment($post_id) )
    1085                             wp_die( __('Error in deleting...') );
    1086                     } else {
    1087                         if ( !wp_delete_post($post_id) )
    1088                             wp_die( __('Error in deleting...') );
    1089                     }
    1090                     $deleted++;
    1091                 }
    1092                 $sendback = add_query_arg('deleted', $deleted, $sendback);
    1093                 break;
    1094             case 'edit':
    1095                 $done = bulk_edit_posts($_REQUEST);
    1096 
    1097                 if ( is_array($done) ) {
    1098                     $done['updated'] = count( $done['updated'] );
    1099                     $done['skipped'] = count( $done['skipped'] );
    1100                     $done['locked'] = count( $done['locked'] );
    1101                     $sendback = add_query_arg( $done, $sendback );
    1102                 }
    1103                 break;
    1104             default :
    1105                 $sendback = apply_filters( "bulk_actions-posts-$doaction", $sendback, $doaction );
    1106                 break;
    1107         }
    1108 
    1109         $sendback = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view' ), $sendback );
    1110         $sendback = $this->add_query_args( $sendback );
    1111         wp_redirect( $sendback );
    1112         exit();
    1113     }
    1114 
    11151016}
    11161017
Note: See TracChangeset for help on using the changeset viewer.