Make WordPress Core


Ignore:
Timestamp:
10/28/2009 02:46:08 AM (17 years ago)
Author:
azaozz
Message:

Undo for posts, pages and media, props caesarsgrunt, see #4529

File:
1 edited

Legend:

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

    r12110 r12121  
    7474                $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
    7575                $doaction = 'delete';
    76         } elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['media']) ) {
    77                 $post_ids = $_GET['media'];
     76        } elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['media']) || isset($_GET['ids']) ) ) {
     77                $post_ids = isset($_GET['media']) ? $_GET['media'] : explode(',', $_GET['ids']);
    7878                $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
    7979        } else
     
    8383        if ( $referer = wp_get_referer() ) {
    8484                if ( false !== strpos($referer, 'upload.php') )
    85                         $location = $referer;
     85                        $location = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'message', 'ids'), $referer );
    8686        }
    8787
     
    9595                                        wp_die( __('Error in moving to trash...') );
    9696                        }
    97                         $location = add_query_arg('message', 4, $location);
     97                        $location = add_query_arg( array( 'message' => 4, 'ids' => join(',', $post_ids) ), $location );
    9898                        break;
    9999                case 'untrash':
     
    203203$messages[2] = __('Media permanently deleted.');
    204204$messages[3] = __('Error saving media attachment.');
    205 $messages[4] = __('Media moved to the trash.') . ' <a href="' . admin_url('upload.php?status=trash') . '">' . __('View trash') . '</a> ';
     205$messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.$_GET['ids'], "bulk-media" ) ) . '">' . __('Undo?') . '</a>';
    206206$messages[5] = __('Media restored from the trash.');
    207207
Note: See TracChangeset for help on using the changeset viewer.