diff --git wp-admin/upload.php wp-admin/upload.php
index d172327..aa868c5 100644
|
|
if ( $doaction ) { |
36 | 36 | $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); |
37 | 37 | } |
38 | 38 | |
| 39 | $errors = array(); |
| 40 | |
| 41 | // Escape item titles displayed in error messages. |
| 42 | add_filter( 'the_title', 'esc_html' ); |
| 43 | |
39 | 44 | switch ( $doaction ) { |
40 | 45 | case 'find_detached': |
41 | 46 | if ( !current_user_can('edit_posts') ) |
… |
… |
if ( $doaction ) { |
90 | 95 | } |
91 | 96 | break; |
92 | 97 | case 'trash': |
93 | | if ( !isset( $post_ids ) ) |
| 98 | if ( ! isset( $post_ids ) ) |
94 | 99 | break; |
95 | 100 | foreach ( (array) $post_ids as $post_id ) { |
96 | | if ( !current_user_can( 'delete_post', $post_id ) ) |
97 | | wp_die( __( 'You are not allowed to move this post to the trash.' ) ); |
| 101 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
| 102 | $errors[] = sprintf( __( 'You are not allowed to move "%s" to the trash.' ), get_the_title( $post_id ) ); |
| 103 | |
| 104 | if ( ! wp_trash_post( $post_id ) ) |
| 105 | $errors[] = sprintf( __( 'There was a problem moving "%s" to the trash.' ), get_the_title( $post_id ) ); |
| 106 | } |
98 | 107 | |
99 | | if ( !wp_trash_post( $post_id ) ) |
100 | | wp_die( __( 'Error in moving to trash...' ) ); |
| 108 | if ( ! empty( $errors ) ) { |
| 109 | $wp_err = new WP_Error(); |
| 110 | if ( count( $errors ) <= 10 ) { |
| 111 | foreach ( $errors as $err ) |
| 112 | $wp_err->add( 'bulk_media_trash_error', $err ); |
| 113 | } else { |
| 114 | $wp_err->add( 'bulk_media_trash_error', sprintf( __( 'There was a problem moving %d items to the trash.' ), count( $errors ) ) ); |
| 115 | } |
| 116 | wp_die( $wp_err ); |
101 | 117 | } |
| 118 | |
102 | 119 | $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); |
103 | 120 | break; |
104 | 121 | case 'untrash': |
105 | | if ( !isset( $post_ids ) ) |
| 122 | if ( ! isset( $post_ids ) ) |
106 | 123 | break; |
107 | 124 | foreach ( (array) $post_ids as $post_id ) { |
108 | | if ( !current_user_can( 'delete_post', $post_id ) ) |
109 | | wp_die( __( 'You are not allowed to move this post out of the trash.' ) ); |
| 125 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
| 126 | $errors[] = sprintf( __( 'You are not allowed to move "%s" out of the trash.' ), get_the_title( $post_id ) ); |
| 127 | |
| 128 | if ( ! wp_untrash_post( $post_id ) ) |
| 129 | $errors[] = sprintf( __( 'There was a problem restoring "%s" from the trash.' ), get_the_title( $post_id ) ); |
| 130 | } |
110 | 131 | |
111 | | if ( !wp_untrash_post( $post_id ) ) |
112 | | wp_die( __( 'Error in restoring from trash...' ) ); |
| 132 | if ( ! empty( $errors ) ) { |
| 133 | $wp_err = new WP_Error(); |
| 134 | if ( count( $errors ) <= 10 ) { |
| 135 | foreach ( $errors as $err ) |
| 136 | $wp_err->add( 'bulk_media_untrash_error', $err ); |
| 137 | } else { |
| 138 | $wp_err->add( 'bulk_media_untrash_error', sprintf( __( 'There was a problem restoring %d items from the trash.' ), count( $errors ) ) ); |
| 139 | } |
| 140 | wp_die( $wp_err ); |
113 | 141 | } |
| 142 | |
114 | 143 | $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); |
115 | 144 | break; |
116 | 145 | case 'delete': |
117 | | if ( !isset( $post_ids ) ) |
| 146 | if ( ! isset( $post_ids ) ) |
118 | 147 | break; |
119 | 148 | foreach ( (array) $post_ids as $post_id_del ) { |
120 | | if ( !current_user_can( 'delete_post', $post_id_del ) ) |
121 | | wp_die( __( 'You are not allowed to delete this post.' ) ); |
| 149 | if ( ! get_post( $post_id_del ) ) |
| 150 | continue; |
| 151 | |
| 152 | if ( ! current_user_can( 'delete_post', $post_id_del ) ) |
| 153 | $errors[] = sprintf( __( 'You are not allowed to delete "%s".' ), get_the_title( $post_id_del ) ); |
122 | 154 | |
123 | | if ( !wp_delete_attachment( $post_id_del ) ) |
124 | | wp_die( __( 'Error in deleting...' ) ); |
| 155 | if ( ! wp_delete_attachment( $post_id_del ) ) |
| 156 | $errors[] = sprintf( __( 'There was a problem deleting "%s".' ), get_the_title( $post_id_del ) ); |
125 | 157 | } |
| 158 | |
| 159 | if ( ! empty( $errors ) ) { |
| 160 | $wp_err = new WP_Error(); |
| 161 | if ( count( $errors ) <= 10 ) { |
| 162 | foreach ( $errors as $err ) |
| 163 | $wp_err->add( 'bulk_media_delete_error', $err ); |
| 164 | } else { |
| 165 | $wp_err->add( 'bulk_media_delete_error', sprintf( __( 'There was a problem deleting %d items.' ), count( $errors ) ) ); |
| 166 | } |
| 167 | wp_die( $wp_err ); |
| 168 | } |
| 169 | |
126 | 170 | $location = add_query_arg( 'deleted', count( $post_ids ), $location ); |
127 | 171 | break; |
128 | 172 | } |