59 '<p>' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '</p>' |
61 '<p>' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '</p>' |
60 ) ); |
62 ) ); |
61 |
63 |
62 get_current_screen()->set_help_sidebar( |
64 get_current_screen()->set_help_sidebar( |
63 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
65 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
64 '<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>' ) . '</p>' . |
66 '<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen">Documentation on Media Library</a>' ) . '</p>' . |
65 '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' |
67 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
66 ); |
68 ); |
67 |
69 |
68 $title = __('Media Library'); |
70 $title = __('Media Library'); |
69 $parent_file = 'upload.php'; |
71 $parent_file = 'upload.php'; |
70 |
72 |
71 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
73 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
72 ?> |
74 ?> |
73 <div class="wrap" id="wp-media-grid" data-search="<?php _admin_search_query() ?>"> |
75 <div class="wrap" id="wp-media-grid" data-search="<?php _admin_search_query() ?>"> |
74 <h2> |
76 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> |
|
77 |
75 <?php |
78 <?php |
76 echo esc_html( $title ); |
|
77 if ( current_user_can( 'upload_files' ) ) { ?> |
79 if ( current_user_can( 'upload_files' ) ) { ?> |
78 <a href="media-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php |
80 <a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php |
79 } |
81 } |
80 ?> |
82 ?> |
81 </h2> |
83 |
|
84 <hr class="wp-header-end"> |
|
85 |
82 <div class="error hide-if-js"> |
86 <div class="error hide-if-js"> |
83 <p><?php _e( 'The grid view for the Media Library requires JavaScript. <a href="upload.php?mode=list">Switch to the list view</a>.' ); ?></p> |
87 <p><?php printf( |
|
88 /* translators: %s: list view URL */ |
|
89 __( 'The grid view for the Media Library requires JavaScript. <a href="%s">Switch to the list view</a>.' ), |
|
90 'upload.php?mode=list' |
|
91 ); ?></p> |
84 </div> |
92 </div> |
85 </div> |
93 </div> |
86 <?php |
94 <?php |
87 include( ABSPATH . 'wp-admin/admin-footer.php' ); |
95 include( ABSPATH . 'wp-admin/admin-footer.php' ); |
88 exit; |
96 exit; |
124 case 'trash': |
132 case 'trash': |
125 if ( !isset( $post_ids ) ) |
133 if ( !isset( $post_ids ) ) |
126 break; |
134 break; |
127 foreach ( (array) $post_ids as $post_id ) { |
135 foreach ( (array) $post_ids as $post_id ) { |
128 if ( !current_user_can( 'delete_post', $post_id ) ) |
136 if ( !current_user_can( 'delete_post', $post_id ) ) |
129 wp_die( __( 'You are not allowed to move this post to the trash.' ) ); |
137 wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); |
130 |
138 |
131 if ( !wp_trash_post( $post_id ) ) |
139 if ( !wp_trash_post( $post_id ) ) |
132 wp_die( __( 'Error in moving to trash.' ) ); |
140 wp_die( __( 'Error in moving to Trash.' ) ); |
133 } |
141 } |
134 $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); |
142 $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); |
135 break; |
143 break; |
136 case 'untrash': |
144 case 'untrash': |
137 if ( !isset( $post_ids ) ) |
145 if ( !isset( $post_ids ) ) |
138 break; |
146 break; |
139 foreach ( (array) $post_ids as $post_id ) { |
147 foreach ( (array) $post_ids as $post_id ) { |
140 if ( !current_user_can( 'delete_post', $post_id ) ) |
148 if ( !current_user_can( 'delete_post', $post_id ) ) |
141 wp_die( __( 'You are not allowed to move this post out of the trash.' ) ); |
149 wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
142 |
150 |
143 if ( !wp_untrash_post( $post_id ) ) |
151 if ( !wp_untrash_post( $post_id ) ) |
144 wp_die( __( 'Error in restoring from trash.' ) ); |
152 wp_die( __( 'Error in restoring from Trash.' ) ); |
145 } |
153 } |
146 $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); |
154 $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); |
147 break; |
155 break; |
148 case 'delete': |
156 case 'delete': |
149 if ( !isset( $post_ids ) ) |
157 if ( !isset( $post_ids ) ) |
150 break; |
158 break; |
151 foreach ( (array) $post_ids as $post_id_del ) { |
159 foreach ( (array) $post_ids as $post_id_del ) { |
152 if ( !current_user_can( 'delete_post', $post_id_del ) ) |
160 if ( !current_user_can( 'delete_post', $post_id_del ) ) |
153 wp_die( __( 'You are not allowed to delete this post.' ) ); |
161 wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); |
154 |
162 |
155 if ( !wp_delete_attachment( $post_id_del ) ) |
163 if ( !wp_delete_attachment( $post_id_del ) ) |
156 wp_die( __( 'Error in deleting.' ) ); |
164 wp_die( __( 'Error in deleting.' ) ); |
157 } |
165 } |
158 $location = add_query_arg( 'deleted', count( $post_ids ), $location ); |
166 $location = add_query_arg( 'deleted', count( $post_ids ), $location ); |
159 break; |
167 break; |
|
168 default: |
|
169 /** This action is documented in wp-admin/edit-comments.php */ |
|
170 $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $doaction, $post_ids ); |
160 } |
171 } |
161 |
172 |
162 wp_redirect( $location ); |
173 wp_redirect( $location ); |
163 exit; |
174 exit; |
164 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
175 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
191 ) ); |
202 ) ); |
192 get_current_screen()->add_help_tab( array( |
203 get_current_screen()->add_help_tab( array( |
193 'id' => 'attaching-files', |
204 'id' => 'attaching-files', |
194 'title' => __('Attaching Files'), |
205 'title' => __('Attaching Files'), |
195 'content' => |
206 'content' => |
196 '<p>' . __( 'If a media file has not been attached to any post, you will see that in the Attached To column, and can click on Attach File to launch a small popup that will allow you to search for a post and attach the file.' ) . '</p>' |
207 '<p>' . __( 'If a media file has not been attached to any content, you will see that in the Uploaded To column, and can click on Attach to launch a small popup that will allow you to search for existing content and attach the file.' ) . '</p>' |
197 ) ); |
208 ) ); |
198 |
209 |
199 get_current_screen()->set_help_sidebar( |
210 get_current_screen()->set_help_sidebar( |
200 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
211 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
201 '<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>' ) . '</p>' . |
212 '<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen">Documentation on Media Library</a>' ) . '</p>' . |
202 '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' |
213 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
203 ); |
214 ); |
|
215 |
|
216 get_current_screen()->set_screen_reader_content( array( |
|
217 'heading_views' => __( 'Filter media items list' ), |
|
218 'heading_pagination' => __( 'Media items list navigation' ), |
|
219 'heading_list' => __( 'Media items list' ), |
|
220 ) ); |
204 |
221 |
205 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
222 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
206 ?> |
223 ?> |
207 |
224 |
208 <div class="wrap"> |
225 <div class="wrap"> |
209 <h2> |
226 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> |
|
227 |
210 <?php |
228 <?php |
211 echo esc_html( $title ); |
|
212 if ( current_user_can( 'upload_files' ) ) { ?> |
229 if ( current_user_can( 'upload_files' ) ) { ?> |
213 <a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a><?php |
230 <a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php |
214 } |
231 } |
215 if ( ! empty( $_REQUEST['s'] ) ) |
232 |
216 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); ?> |
233 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
217 </h2> |
234 /* translators: %s: search keywords */ |
|
235 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', get_search_query() ); |
|
236 } |
|
237 ?> |
|
238 |
|
239 <hr class="wp-header-end"> |
218 |
240 |
219 <?php |
241 <?php |
220 $message = ''; |
242 $message = ''; |
221 if ( ! empty( $_GET['posted'] ) ) { |
243 if ( ! empty( $_GET['posted'] ) ) { |
222 $message = __( 'Media attachment updated.' ); |
244 $message = __( 'Media file updated.' ); |
223 $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
245 $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
224 } |
246 } |
225 |
247 |
226 if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) { |
248 if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) { |
227 $message = sprintf( _n( 'Reattached %d attachment.', 'Reattached %d attachments.', $attached ), $attached ); |
249 if ( 1 == $attached ) { |
|
250 $message = __( 'Media file attached.' ); |
|
251 } else { |
|
252 /* translators: %s: number of media files */ |
|
253 $message = _n( '%s media file attached.', '%s media files attached.', $attached ); |
|
254 } |
|
255 $message = sprintf( $message, number_format_i18n( $attached ) ); |
228 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); |
256 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); |
229 } |
257 } |
230 |
258 |
231 if ( ! empty( $_GET['detach'] ) && $detached = absint( $_GET['detach'] ) ) { |
259 if ( ! empty( $_GET['detach'] ) && $detached = absint( $_GET['detach'] ) ) { |
232 $message = sprintf( _n( 'Detached %d attachment.', 'Detached %d attachments.', $detached ), $detached ); |
260 if ( 1 == $detached ) { |
|
261 $message = __( 'Media file detached.' ); |
|
262 } else { |
|
263 /* translators: %s: number of media files */ |
|
264 $message = _n( '%s media file detached.', '%s media files detached.', $detached ); |
|
265 } |
|
266 $message = sprintf( $message, number_format_i18n( $detached ) ); |
233 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); |
267 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); |
234 } |
268 } |
235 |
269 |
236 if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) { |
270 if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) { |
237 if ( 1 == $deleted ) { |
271 if ( 1 == $deleted ) { |
238 $message = __( 'Media attachment permanently deleted.' ); |
272 $message = __( 'Media file permanently deleted.' ); |
239 } else { |
273 } else { |
240 $message = _n( '%d media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted ); |
274 /* translators: %s: number of media files */ |
|
275 $message = _n( '%s media file permanently deleted.', '%s media files permanently deleted.', $deleted ); |
241 } |
276 } |
242 $message = sprintf( $message, number_format_i18n( $deleted ) ); |
277 $message = sprintf( $message, number_format_i18n( $deleted ) ); |
243 $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']); |
278 $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']); |
244 } |
279 } |
245 |
280 |
246 if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) { |
281 if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) { |
247 if ( 1 == $trashed ) { |
282 if ( 1 == $trashed ) { |
248 $message = __( 'Media attachment moved to the trash.' ); |
283 $message = __( 'Media file moved to the trash.' ); |
249 } else { |
284 } else { |
250 $message = _n( '%d media attachment moved to the trash.', '%d media attachments moved to the trash.', $trashed ); |
285 /* translators: %s: number of media files */ |
|
286 $message = _n( '%s media file moved to the trash.', '%s media files moved to the trash.', $trashed ); |
251 } |
287 } |
252 $message = sprintf( $message, number_format_i18n( $trashed ) ); |
288 $message = sprintf( $message, number_format_i18n( $trashed ) ); |
253 $message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>'; |
289 $message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>'; |
254 $_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']); |
290 $_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']); |
255 } |
291 } |
256 |
292 |
257 if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) { |
293 if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) { |
258 if ( 1 == $untrashed ) { |
294 if ( 1 == $untrashed ) { |
259 $message = __( 'Media attachment restored from the trash.' ); |
295 $message = __( 'Media file restored from the trash.' ); |
260 } else { |
296 } else { |
261 $message = _n( '%d media attachment restored from the trash.', '%d media attachments restored from the trash.', $untrashed ); |
297 /* translators: %s: number of media files */ |
|
298 $message = _n( '%s media file restored from the trash.', '%s media files restored from the trash.', $untrashed ); |
262 } |
299 } |
263 $message = sprintf( $message, number_format_i18n( $untrashed ) ); |
300 $message = sprintf( $message, number_format_i18n( $untrashed ) ); |
264 $_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']); |
301 $_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']); |
265 } |
302 } |
266 |
303 |
267 $messages[1] = __('Media attachment updated.'); |
304 $messages[1] = __( 'Media file updated.' ); |
268 $messages[2] = __('Media permanently deleted.'); |
305 $messages[2] = __( 'Media file permanently deleted.' ); |
269 $messages[3] = __('Error saving media attachment.'); |
306 $messages[3] = __( 'Error saving media file.' ); |
270 $messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>'; |
307 $messages[4] = __( 'Media file moved to the trash.' ) . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __( 'Undo' ) . '</a>'; |
271 $messages[5] = __('Media restored from the trash.'); |
308 $messages[5] = __( 'Media file restored from the trash.' ); |
272 |
309 |
273 if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) { |
310 if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) { |
274 $message = $messages[ $_GET['message'] ]; |
311 $message = $messages[ $_GET['message'] ]; |
275 $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); |
312 $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); |
276 } |
313 } |