diff --git wp-admin/upload.php wp-admin/upload.php
index d172327..5e5a185 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 ) { |
| 94 | 99 | break; |
| 95 | 100 | foreach ( (array) $post_ids as $post_id ) { |
| 96 | 101 | if ( !current_user_can( 'delete_post', $post_id ) ) |
| 97 | | wp_die( __( 'You are not allowed to move this post to the trash.' ) ); |
| | 102 | $errors[] = sprintf( __( 'You are not allowed to move "%s" to the trash.' ), get_the_title( $post_id ) ); |
| 98 | 103 | |
| 99 | 104 | if ( !wp_trash_post( $post_id ) ) |
| 100 | | wp_die( __( 'Error in moving to trash...' ) ); |
| | 105 | $errors[] = sprintf( __( 'There was a problem moving "%s" to the trash.' ), get_the_title( $post_id ) ); |
| | 106 | } |
| | 107 | |
| | 108 | if( ! empty( $errors ) ) { |
| | 109 | $wp_err = new WP_Error(); |
| | 110 | foreach( $errors as $err ) |
| | 111 | $wp_err->add( 'bulk_media_trash_error', $err ); |
| | 112 | wp_die( $wp_err ); |
| 101 | 113 | } |
| | 114 | |
| 102 | 115 | $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); |
| 103 | 116 | break; |
| 104 | 117 | case 'untrash': |
| … |
… |
if ( $doaction ) { |
| 106 | 119 | break; |
| 107 | 120 | foreach ( (array) $post_ids as $post_id ) { |
| 108 | 121 | if ( !current_user_can( 'delete_post', $post_id ) ) |
| 109 | | wp_die( __( 'You are not allowed to move this post out of the trash.' ) ); |
| | 122 | $errors[] = sprintf( __( 'You are not allowed to move "%s" out of the trash.' ), get_the_title( $post_id ) ); |
| 110 | 123 | |
| 111 | 124 | if ( !wp_untrash_post( $post_id ) ) |
| 112 | | wp_die( __( 'Error in restoring from trash...' ) ); |
| | 125 | $errors[] = sprintf( __( 'There was a problem restoring "%s" from the trash.' ), get_the_title( $post_id ) ); |
| | 126 | } |
| | 127 | |
| | 128 | if( ! empty( $errors ) ) { |
| | 129 | $wp_err = new WP_Error(); |
| | 130 | foreach( $errors as $err ) |
| | 131 | $wp_err->add( 'bulk_media_untrash_error', $err ); |
| | 132 | wp_die( $wp_err ); |
| 113 | 133 | } |
| | 134 | |
| 114 | 135 | $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); |
| 115 | 136 | break; |
| 116 | 137 | case 'delete': |
| 117 | 138 | if ( !isset( $post_ids ) ) |
| 118 | 139 | break; |
| 119 | 140 | foreach ( (array) $post_ids as $post_id_del ) { |
| | 141 | if( !get_post( $post_id_del ) ) |
| | 142 | continue; |
| | 143 | |
| 120 | 144 | if ( !current_user_can( 'delete_post', $post_id_del ) ) |
| 121 | | wp_die( __( 'You are not allowed to delete this post.' ) ); |
| | 145 | $errors[] = sprintf( __( 'You are not allowed to delete "%s".' ), get_the_title( $post_id_del ) ); |
| 122 | 146 | |
| 123 | 147 | if ( !wp_delete_attachment( $post_id_del ) ) |
| 124 | | wp_die( __( 'Error in deleting...' ) ); |
| | 148 | $errors[] = sprintf( __( 'There was a problem deleting "%s".' ), get_the_title( $post_id_del ) ); |
| 125 | 149 | } |
| | 150 | |
| | 151 | if( ! empty( $errors ) ) { |
| | 152 | $wp_err = new WP_Error(); |
| | 153 | foreach( $errors as $err ) |
| | 154 | $wp_err->add( 'bulk_media_delete_error', $err ); |
| | 155 | wp_die( $wp_err ); |
| | 156 | } |
| | 157 | |
| 126 | 158 | $location = add_query_arg( 'deleted', count( $post_ids ), $location ); |
| 127 | 159 | break; |
| 128 | 160 | } |