69 public function prepare_items() { |
69 public function prepare_items() { |
70 global $mode, $wp_query, $post_mime_types, $avail_post_mime_types; |
70 global $mode, $wp_query, $post_mime_types, $avail_post_mime_types; |
71 |
71 |
72 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
72 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
73 |
73 |
74 // Exclude attachments scheduled for deletion in the next two hours |
74 /* |
75 // if they are for zip packages for interrupted or failed updates. |
75 * Exclude attachments scheduled for deletion in the next two hours |
76 // See File_Upload_Upgrader class. |
76 * if they are for zip packages for interrupted or failed updates. |
|
77 * See File_Upload_Upgrader class. |
|
78 */ |
77 $not_in = array(); |
79 $not_in = array(); |
78 |
80 |
79 foreach ( _get_cron_array() as $cron ) { |
81 foreach ( _get_cron_array() as $cron ) { |
80 if ( isset( $cron['upgrader_scheduled_cleanup'] ) ) { |
82 if ( isset( $cron['upgrader_scheduled_cleanup'] ) ) { |
81 $details = reset( $cron['upgrader_scheduled_cleanup'] ); |
83 $details = reset( $cron['upgrader_scheduled_cleanup'] ); |
194 if ( 'bar' !== $which ) { |
197 if ( 'bar' !== $which ) { |
195 return; |
198 return; |
196 } |
199 } |
197 ?> |
200 ?> |
198 <div class="actions"> |
201 <div class="actions"> |
199 <?php |
202 <?php |
200 if ( ! $this->is_trash ) { |
203 if ( ! $this->is_trash ) { |
201 $this->months_dropdown( 'attachment' ); |
204 $this->months_dropdown( 'attachment' ); |
202 } |
205 } |
203 |
206 |
204 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
207 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
205 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
208 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
206 |
209 |
207 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
210 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
208 |
211 |
209 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { |
212 if ( $this->is_trash && $this->has_items() |
210 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
213 && current_user_can( 'edit_others_posts' ) |
211 } |
214 ) { |
212 ?> |
215 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
|
216 } |
|
217 ?> |
213 </div> |
218 </div> |
214 <?php |
219 <?php |
215 } |
220 } |
216 |
221 |
217 /** |
222 /** |
260 |
265 |
261 $views = $this->get_views(); |
266 $views = $this->get_views(); |
262 |
267 |
263 $this->screen->render_screen_reader_content( 'heading_views' ); |
268 $this->screen->render_screen_reader_content( 'heading_views' ); |
264 ?> |
269 ?> |
265 <div class="wp-filter"> |
270 <div class="wp-filter"> |
266 <div class="filter-items"> |
271 <div class="filter-items"> |
267 <?php $this->view_switcher( $mode ); ?> |
272 <?php $this->view_switcher( $mode ); ?> |
268 |
273 |
269 <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label> |
274 <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label> |
270 <select class="attachment-filters" name="attachment-filter" id="attachment-filter"> |
275 <select class="attachment-filters" name="attachment-filter" id="attachment-filter"> |
271 <?php |
276 <?php |
272 if ( ! empty( $views ) ) { |
277 if ( ! empty( $views ) ) { |
273 foreach ( $views as $class => $view ) { |
278 foreach ( $views as $class => $view ) { |
274 echo "\t$view\n"; |
279 echo "\t$view\n"; |
|
280 } |
|
281 } |
|
282 ?> |
|
283 </select> |
|
284 |
|
285 <?php |
|
286 $this->extra_tablenav( 'bar' ); |
|
287 |
|
288 /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
|
289 $views = apply_filters( "views_{$this->screen->id}", array() ); |
|
290 |
|
291 // Back compat for pre-4.0 view links. |
|
292 if ( ! empty( $views ) ) { |
|
293 echo '<ul class="filter-links">'; |
|
294 foreach ( $views as $class => $view ) { |
|
295 echo "<li class='$class'>$view</li>"; |
|
296 } |
|
297 echo '</ul>'; |
275 } |
298 } |
276 } |
299 ?> |
277 ?> |
300 </div> |
278 </select> |
301 |
279 |
302 <div class="search-form"> |
280 <?php |
303 <label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label> |
281 $this->extra_tablenav( 'bar' ); |
304 <input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"> |
282 |
305 </div> |
283 /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
306 </div> |
284 $views = apply_filters( "views_{$this->screen->id}", array() ); |
|
285 |
|
286 // Back compat for pre-4.0 view links. |
|
287 if ( ! empty( $views ) ) { |
|
288 echo '<ul class="filter-links">'; |
|
289 foreach ( $views as $class => $view ) { |
|
290 echo "<li class='$class'>$view</li>"; |
|
291 } |
|
292 echo '</ul>'; |
|
293 } |
|
294 ?> |
|
295 </div> |
|
296 |
|
297 <div class="search-form"> |
|
298 <label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label> |
|
299 <input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div> |
|
300 </div> |
|
301 <?php |
307 <?php |
302 } |
308 } |
303 |
309 |
304 /** |
310 /** |
305 * @return array |
311 * @return array |
331 } elseif ( 'post_tag' === $taxonomy ) { |
337 } elseif ( 'post_tag' === $taxonomy ) { |
332 $column_key = 'tags'; |
338 $column_key = 'tags'; |
333 } else { |
339 } else { |
334 $column_key = 'taxonomy-' . $taxonomy; |
340 $column_key = 'taxonomy-' . $taxonomy; |
335 } |
341 } |
|
342 |
336 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
343 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
337 } |
344 } |
338 |
345 |
339 /* translators: Column name. */ |
346 /* translators: Column name. */ |
340 if ( ! $this->detached ) { |
347 if ( ! $this->detached ) { |
341 $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
348 $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
342 if ( post_type_supports( 'attachment', 'comments' ) ) { |
349 if ( post_type_supports( 'attachment', 'comments' ) ) { |
343 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
350 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
344 } |
351 } |
345 } |
352 } |
|
353 |
346 /* translators: Column name. */ |
354 /* translators: Column name. */ |
347 $posts_columns['date'] = _x( 'Date', 'column name' ); |
355 $posts_columns['date'] = _x( 'Date', 'column name' ); |
|
356 |
348 /** |
357 /** |
349 * Filters the Media list table columns. |
358 * Filters the Media list table columns. |
350 * |
359 * |
351 * @since 2.5.0 |
360 * @since 2.5.0 |
352 * |
361 * |
419 $class = $thumb ? ' class="has-media-icon"' : ''; |
428 $class = $thumb ? ' class="has-media-icon"' : ''; |
420 ?> |
429 ?> |
421 <strong<?php echo $class; ?>> |
430 <strong<?php echo $class; ?>> |
422 <?php |
431 <?php |
423 echo $link_start; |
432 echo $link_start; |
|
433 |
424 if ( $thumb ) : |
434 if ( $thumb ) : |
425 ?> |
435 ?> |
426 <span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span> |
436 <span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span> |
427 <?php |
437 <?php |
428 endif; |
438 endif; |
|
439 |
429 echo $title . $link_end; |
440 echo $title . $link_end; |
|
441 |
430 _media_states( $post ); |
442 _media_states( $post ); |
431 ?> |
443 ?> |
432 </strong> |
444 </strong> |
433 <p class="filename"> |
445 <p class="filename"> |
434 <span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span> |
446 <span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span> |
510 if ( $parent ) { |
522 if ( $parent ) { |
511 $title = _draft_or_post_title( $post->post_parent ); |
523 $title = _draft_or_post_title( $post->post_parent ); |
512 $parent_type = get_post_type_object( $parent->post_type ); |
524 $parent_type = get_post_type_object( $parent->post_type ); |
513 |
525 |
514 if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { |
526 if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { |
515 ?> |
527 printf( '<strong><a href="%s">%s</a></strong>', get_edit_post_link( $post->post_parent ), $title ); |
516 <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"> |
|
517 <?php echo $title; ?></a></strong> |
|
518 <?php |
|
519 } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { |
528 } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { |
520 ?> |
529 printf( '<strong>%s</strong>', $title ); |
521 <strong><?php echo $title; ?></strong> |
|
522 <?php |
|
523 } else { |
530 } else { |
524 _e( '(Private post)' ); |
531 _e( '(Private post)' ); |
525 } |
532 } |
526 |
533 |
527 if ( $user_can_edit ) : |
534 if ( $user_can_edit ) : |
598 $taxonomy = false; |
605 $taxonomy = false; |
599 } |
606 } |
600 |
607 |
601 if ( $taxonomy ) { |
608 if ( $taxonomy ) { |
602 $terms = get_the_terms( $post->ID, $taxonomy ); |
609 $terms = get_the_terms( $post->ID, $taxonomy ); |
|
610 |
603 if ( is_array( $terms ) ) { |
611 if ( is_array( $terms ) ) { |
604 $out = array(); |
612 $out = array(); |
605 foreach ( $terms as $t ) { |
613 foreach ( $terms as $t ) { |
606 $posts_in_term_qv = array(); |
614 $posts_in_term_qv = array(); |
607 $posts_in_term_qv['taxonomy'] = $taxonomy; |
615 $posts_in_term_qv['taxonomy'] = $taxonomy; |
612 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
620 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
613 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
621 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
614 ); |
622 ); |
615 } |
623 } |
616 /* translators: Used between list items, there is a space after the comma. */ |
624 /* translators: Used between list items, there is a space after the comma. */ |
617 echo join( __( ', ' ), $out ); |
625 echo implode( __( ', ' ), $out ); |
618 } else { |
626 } else { |
619 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>'; |
627 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>'; |
620 } |
628 } |
621 |
629 |
622 return; |
630 return; |
648 |
656 |
649 add_filter( 'the_title', 'esc_html' ); |
657 add_filter( 'the_title', 'esc_html' ); |
650 |
658 |
651 while ( have_posts() ) : |
659 while ( have_posts() ) : |
652 the_post(); |
660 the_post(); |
653 if ( |
661 |
654 ( $this->is_trash && 'trash' !== $post->post_status ) |
662 if ( $this->is_trash && 'trash' !== $post->post_status |
655 || ( ! $this->is_trash && 'trash' === $post->post_status ) |
663 || ! $this->is_trash && 'trash' === $post->post_status |
656 ) { |
664 ) { |
657 continue; |
665 continue; |
658 } |
666 } |
659 $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; |
667 |
|
668 $post_owner = ( get_current_user_id() === (int) $post->post_author ) ? 'self' : 'other'; |
660 ?> |
669 ?> |
661 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> |
670 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> |
662 <?php $this->single_row_columns( $post ); ?> |
671 <?php $this->single_row_columns( $post ); ?> |
663 </tr> |
672 </tr> |
664 <?php |
673 <?php |
692 /* translators: %s: Attachment title. */ |
701 /* translators: %s: Attachment title. */ |
693 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
702 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
694 __( 'Edit' ) |
703 __( 'Edit' ) |
695 ); |
704 ); |
696 } |
705 } |
|
706 |
697 if ( current_user_can( 'delete_post', $post->ID ) ) { |
707 if ( current_user_can( 'delete_post', $post->ID ) ) { |
698 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
708 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
699 $actions['trash'] = sprintf( |
709 $actions['trash'] = sprintf( |
700 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
710 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
701 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
711 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
713 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
723 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
714 __( 'Delete Permanently' ) |
724 __( 'Delete Permanently' ) |
715 ); |
725 ); |
716 } |
726 } |
717 } |
727 } |
|
728 |
718 $actions['view'] = sprintf( |
729 $actions['view'] = sprintf( |
719 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
730 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
720 get_permalink( $post->ID ), |
731 get_permalink( $post->ID ), |
721 /* translators: %s: Attachment title. */ |
732 /* translators: %s: Attachment title. */ |
722 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
733 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
740 /* translators: %s: Attachment title. */ |
751 /* translators: %s: Attachment title. */ |
741 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
752 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
742 __( 'Edit' ) |
753 __( 'Edit' ) |
743 ); |
754 ); |
744 } |
755 } |
|
756 |
745 if ( current_user_can( 'delete_post', $post->ID ) ) { |
757 if ( current_user_can( 'delete_post', $post->ID ) ) { |
746 if ( $this->is_trash ) { |
758 if ( $this->is_trash ) { |
747 $actions['untrash'] = sprintf( |
759 $actions['untrash'] = sprintf( |
748 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
760 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
749 wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), |
761 wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), |
758 /* translators: %s: Attachment title. */ |
770 /* translators: %s: Attachment title. */ |
759 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
771 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
760 _x( 'Trash', 'verb' ) |
772 _x( 'Trash', 'verb' ) |
761 ); |
773 ); |
762 } |
774 } |
|
775 |
763 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
776 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
764 $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
777 $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
765 $actions['delete'] = sprintf( |
778 $actions['delete'] = sprintf( |
766 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
779 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
767 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
780 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
770 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
783 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
771 __( 'Delete Permanently' ) |
784 __( 'Delete Permanently' ) |
772 ); |
785 ); |
773 } |
786 } |
774 } |
787 } |
|
788 |
775 if ( ! $this->is_trash ) { |
789 if ( ! $this->is_trash ) { |
776 $actions['view'] = sprintf( |
790 $actions['view'] = sprintf( |
777 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
791 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
778 get_permalink( $post->ID ), |
792 get_permalink( $post->ID ), |
779 /* translators: %s: Attachment title. */ |
793 /* translators: %s: Attachment title. */ |
800 /** |
814 /** |
801 * Generates and displays row action links. |
815 * Generates and displays row action links. |
802 * |
816 * |
803 * @since 4.3.0 |
817 * @since 4.3.0 |
804 * |
818 * |
805 * @param object $post Attachment being acted upon. |
819 * @param WP_Post $post Attachment being acted upon. |
806 * @param string $column_name Current column name. |
820 * @param string $column_name Current column name. |
807 * @param string $primary Primary column name. |
821 * @param string $primary Primary column name. |
808 * @return string Row actions output for media attachments, or an empty string |
822 * @return string Row actions output for media attachments, or an empty string |
809 * if the current column is not the primary column. |
823 * if the current column is not the primary column. |
810 */ |
824 */ |
811 protected function handle_row_actions( $post, $column_name, $primary ) { |
825 protected function handle_row_actions( $post, $column_name, $primary ) { |
812 if ( $primary !== $column_name ) { |
826 if ( $primary !== $column_name ) { |