| changeset 16 | a86126ab1dd4 |
| parent 9 | 177826044cd9 |
| child 18 | be944660c56a |
| 15:3d4e9c994f10 | 16:a86126ab1dd4 |
|---|---|
39 */ |
39 */ |
40 public function __construct( $args = array() ) { |
40 public function __construct( $args = array() ) { |
41 $this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] ); |
41 $this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] ); |
42 |
42 |
43 $this->modes = array( |
43 $this->modes = array( |
44 'list' => __( 'List View' ), |
44 'list' => __( 'List view' ), |
45 'grid' => __( 'Grid View' ), |
45 'grid' => __( 'Grid view' ), |
46 ); |
46 ); |
47 |
47 |
48 parent::__construct( |
48 parent::__construct( |
49 array( |
49 array( |
50 'plural' => 'media', |
50 'plural' => 'media', |
59 public function ajax_user_can() { |
59 public function ajax_user_can() { |
60 return current_user_can( 'upload_files' ); |
60 return current_user_can( 'upload_files' ); |
61 } |
61 } |
62 |
62 |
63 /** |
63 /** |
64 * @global WP_Query $wp_query |
64 * @global string $mode List table view mode. |
65 * @global WP_Query $wp_query WordPress Query object. |
|
65 * @global array $post_mime_types |
66 * @global array $post_mime_types |
66 * @global array $avail_post_mime_types |
67 * @global array $avail_post_mime_types |
67 * @global string $mode |
|
68 */ |
68 */ |
69 public function prepare_items() { |
69 public function prepare_items() { |
70 global $wp_query, $post_mime_types, $avail_post_mime_types, $mode; |
70 global $mode, $wp_query, $post_mime_types, $avail_post_mime_types; |
71 |
|
72 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
73 |
|
74 // Exclude attachments scheduled for deletion in the next two hours |
|
75 // if they are for zip packages for interrupted or failed updates. |
|
76 // See File_Upload_Upgrader class. |
|
77 $not_in = array(); |
|
78 |
|
79 foreach ( _get_cron_array() as $cron ) { |
|
80 if ( isset( $cron['upgrader_scheduled_cleanup'] ) ) { |
|
81 $details = reset( $cron['upgrader_scheduled_cleanup'] ); |
|
82 |
|
83 if ( ! empty( $details['args'][0] ) ) { |
|
84 $not_in[] = (int) $details['args'][0]; |
|
85 } |
|
86 } |
|
87 } |
|
88 |
|
89 if ( ! empty( $_REQUEST['post__not_in'] ) && is_array( $_REQUEST['post__not_in'] ) ) { |
|
90 $not_in = array_merge( array_values( $_REQUEST['post__not_in'] ), $not_in ); |
|
91 } |
|
92 |
|
93 if ( ! empty( $not_in ) ) { |
|
94 $_REQUEST['post__not_in'] = $not_in; |
|
95 } |
|
71 |
96 |
72 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); |
97 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); |
73 |
98 |
74 $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; |
99 $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; |
75 |
|
76 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
77 |
100 |
78 $this->set_pagination_args( |
101 $this->set_pagination_args( |
79 array( |
102 array( |
80 'total_items' => $wp_query->found_posts, |
103 'total_items' => $wp_query->found_posts, |
81 'total_pages' => $wp_query->max_num_pages, |
104 'total_pages' => $wp_query->max_num_pages, |
147 protected function get_bulk_actions() { |
170 protected function get_bulk_actions() { |
148 $actions = array(); |
171 $actions = array(); |
149 if ( MEDIA_TRASH ) { |
172 if ( MEDIA_TRASH ) { |
150 if ( $this->is_trash ) { |
173 if ( $this->is_trash ) { |
151 $actions['untrash'] = __( 'Restore' ); |
174 $actions['untrash'] = __( 'Restore' ); |
152 $actions['delete'] = __( 'Delete Permanently' ); |
175 $actions['delete'] = __( 'Delete permanently' ); |
153 } else { |
176 } else { |
154 $actions['trash'] = __( 'Move to Trash' ); |
177 $actions['trash'] = __( 'Move to Trash' ); |
155 } |
178 } |
156 } else { |
179 } else { |
157 $actions['delete'] = __( 'Delete Permanently' ); |
180 $actions['delete'] = __( 'Delete permanently' ); |
158 } |
181 } |
159 |
182 |
160 if ( $this->detached ) { |
183 if ( $this->detached ) { |
161 $actions['attach'] = __( 'Attach' ); |
184 $actions['attach'] = __( 'Attach' ); |
162 } |
185 } |
172 return; |
195 return; |
173 } |
196 } |
174 ?> |
197 ?> |
175 <div class="actions"> |
198 <div class="actions"> |
176 <?php |
199 <?php |
177 if ( ! is_singular() ) { |
200 if ( ! $this->is_trash ) { |
178 if ( ! $this->is_trash ) { |
201 $this->months_dropdown( 'attachment' ); |
179 $this->months_dropdown( 'attachment' ); |
202 } |
180 } |
203 |
181 |
204 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
182 /** 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 ); |
183 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
206 |
184 |
207 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
185 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
186 } |
|
187 |
208 |
188 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { |
209 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { |
189 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
210 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
190 } |
211 } |
191 ?> |
212 ?> |
220 } |
241 } |
221 |
242 |
222 /** |
243 /** |
223 */ |
244 */ |
224 public function no_items() { |
245 public function no_items() { |
225 _e( 'No media files found.' ); |
246 if ( $this->is_trash ) { |
247 _e( 'No media files found in Trash.' ); |
|
248 } else { |
|
249 _e( 'No media files found.' ); |
|
250 } |
|
226 } |
251 } |
227 |
252 |
228 /** |
253 /** |
229 * Override parent views so we can use the filter bar display. |
254 * Override parent views so we can use the filter bar display. |
230 * |
255 * |
268 } |
293 } |
269 ?> |
294 ?> |
270 </div> |
295 </div> |
271 |
296 |
272 <div class="search-form"> |
297 <div class="search-form"> |
273 <label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label> |
298 <label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label> |
274 <input type="search" placeholder="<?php esc_attr_e( 'Search media items...' ); ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div> |
299 <input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div> |
275 </div> |
300 </div> |
276 <?php |
301 <?php |
277 } |
302 } |
278 |
303 |
279 /** |
304 /** |
280 * @return array |
305 * @return array |
281 */ |
306 */ |
282 public function get_columns() { |
307 public function get_columns() { |
283 $posts_columns = array(); |
308 $posts_columns = array(); |
284 $posts_columns['cb'] = '<input type="checkbox" />'; |
309 $posts_columns['cb'] = '<input type="checkbox" />'; |
285 /* translators: column name */ |
310 /* translators: Column name. */ |
286 $posts_columns['title'] = _x( 'File', 'column name' ); |
311 $posts_columns['title'] = _x( 'File', 'column name' ); |
287 $posts_columns['author'] = __( 'Author' ); |
312 $posts_columns['author'] = __( 'Author' ); |
288 |
313 |
289 $taxonomies = get_taxonomies_for_attachments( 'objects' ); |
314 $taxonomies = get_taxonomies_for_attachments( 'objects' ); |
290 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
315 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
309 $column_key = 'taxonomy-' . $taxonomy; |
334 $column_key = 'taxonomy-' . $taxonomy; |
310 } |
335 } |
311 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
336 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
312 } |
337 } |
313 |
338 |
314 /* translators: column name */ |
339 /* translators: Column name. */ |
315 if ( ! $this->detached ) { |
340 if ( ! $this->detached ) { |
316 $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
341 $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
317 if ( post_type_supports( 'attachment', 'comments' ) ) { |
342 if ( post_type_supports( 'attachment', 'comments' ) ) { |
318 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
343 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
319 } |
344 } |
320 } |
345 } |
321 /* translators: column name */ |
346 /* translators: Column name. */ |
322 $posts_columns['date'] = _x( 'Date', 'column name' ); |
347 $posts_columns['date'] = _x( 'Date', 'column name' ); |
323 /** |
348 /** |
324 * Filters the Media list table columns. |
349 * Filters the Media list table columns. |
325 * |
350 * |
326 * @since 2.5.0 |
351 * @since 2.5.0 |
354 */ |
379 */ |
355 public function column_cb( $post ) { |
380 public function column_cb( $post ) { |
356 if ( current_user_can( 'edit_post', $post->ID ) ) { |
381 if ( current_user_can( 'edit_post', $post->ID ) ) { |
357 ?> |
382 ?> |
358 <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"> |
383 <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"> |
359 <?php |
384 <?php |
360 echo sprintf( __( 'Select %s' ), _draft_or_post_title() ); |
385 /* translators: %s: Attachment title. */ |
361 ?> |
386 printf( __( 'Select %s' ), _draft_or_post_title() ); |
387 ?> |
|
362 </label> |
388 </label> |
363 <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> |
389 <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> |
364 <?php |
390 <?php |
365 } |
391 } |
366 } |
392 } |
375 public function column_title( $post ) { |
401 public function column_title( $post ) { |
376 list( $mime ) = explode( '/', $post->post_mime_type ); |
402 list( $mime ) = explode( '/', $post->post_mime_type ); |
377 |
403 |
378 $title = _draft_or_post_title(); |
404 $title = _draft_or_post_title(); |
379 $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); |
405 $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); |
380 $link_start = $link_end = ''; |
406 $link_start = ''; |
407 $link_end = ''; |
|
381 |
408 |
382 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
409 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
383 $link_start = sprintf( |
410 $link_start = sprintf( |
384 '<a href="%s" aria-label="%s">', |
411 '<a href="%s" aria-label="%s">', |
385 get_edit_post_link( $post->ID ), |
412 get_edit_post_link( $post->ID ), |
386 /* translators: %s: attachment title */ |
413 /* translators: %s: Attachment title. */ |
387 esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ) |
414 esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ) |
388 ); |
415 ); |
389 $link_end = '</a>'; |
416 $link_end = '</a>'; |
390 } |
417 } |
391 |
418 |
448 */ |
475 */ |
449 public function column_date( $post ) { |
476 public function column_date( $post ) { |
450 if ( '0000-00-00 00:00:00' === $post->post_date ) { |
477 if ( '0000-00-00 00:00:00' === $post->post_date ) { |
451 $h_time = __( 'Unpublished' ); |
478 $h_time = __( 'Unpublished' ); |
452 } else { |
479 } else { |
453 $m_time = $post->post_date; |
480 $time = get_post_timestamp( $post ); |
454 $time = get_post_time( 'G', true, $post, false ); |
481 $time_diff = time() - $time; |
455 if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) { |
482 |
456 if ( $t_diff < 0 ) { |
483 if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
457 $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); |
484 /* translators: %s: Human-readable time difference. */ |
458 } else { |
485 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
459 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
460 } |
|
461 } else { |
486 } else { |
462 $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
487 $h_time = get_the_time( __( 'Y/m/d' ), $post ); |
463 } |
488 } |
464 } |
489 } |
465 |
490 |
466 echo $h_time; |
491 echo $h_time; |
467 } |
492 } |
509 'upload.php' |
534 'upload.php' |
510 ); |
535 ); |
511 printf( |
536 printf( |
512 '<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>', |
537 '<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>', |
513 $detach_url, |
538 $detach_url, |
514 /* translators: %s: title of the post the attachment is attached to */ |
539 /* translators: %s: Title of the post the attachment is attached to. */ |
515 esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), |
540 esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), |
516 __( 'Detach' ) |
541 __( 'Detach' ) |
517 ); |
542 ); |
518 endif; |
543 endif; |
519 } else { |
544 } else { |
523 if ( $user_can_edit ) { |
548 if ( $user_can_edit ) { |
524 $title = _draft_or_post_title( $post->post_parent ); |
549 $title = _draft_or_post_title( $post->post_parent ); |
525 printf( |
550 printf( |
526 '<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
551 '<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
527 $post->ID, |
552 $post->ID, |
528 /* translators: %s: attachment title */ |
553 /* translators: %s: Attachment title. */ |
529 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ), |
554 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ), |
530 __( 'Attach' ) |
555 __( 'Attach' ) |
531 ); |
556 ); |
532 } |
557 } |
533 } |
558 } |
586 '<a href="%s">%s</a>', |
611 '<a href="%s">%s</a>', |
587 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
612 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
588 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
613 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
589 ); |
614 ); |
590 } |
615 } |
591 /* translators: used between list items, there is a space after the comma */ |
616 /* translators: Used between list items, there is a space after the comma. */ |
592 echo join( __( ', ' ), $out ); |
617 echo join( __( ', ' ), $out ); |
593 } else { |
618 } else { |
594 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>'; |
619 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>'; |
595 } |
620 } |
596 |
621 |
609 */ |
634 */ |
610 do_action( 'manage_media_custom_column', $column_name, $post->ID ); |
635 do_action( 'manage_media_custom_column', $column_name, $post->ID ); |
611 } |
636 } |
612 |
637 |
613 /** |
638 /** |
614 * @global WP_Post $post |
639 * @global WP_Post $post Global post object. |
615 */ |
640 */ |
616 public function display_rows() { |
641 public function display_rows() { |
617 global $post, $wp_query; |
642 global $post, $wp_query; |
618 |
643 |
619 $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); |
644 $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); |
624 add_filter( 'the_title', 'esc_html' ); |
649 add_filter( 'the_title', 'esc_html' ); |
625 |
650 |
626 while ( have_posts() ) : |
651 while ( have_posts() ) : |
627 the_post(); |
652 the_post(); |
628 if ( |
653 if ( |
629 ( $this->is_trash && $post->post_status != 'trash' ) |
654 ( $this->is_trash && 'trash' !== $post->post_status ) |
630 || ( ! $this->is_trash && $post->post_status === 'trash' ) |
655 || ( ! $this->is_trash && 'trash' === $post->post_status ) |
631 ) { |
656 ) { |
632 continue; |
657 continue; |
633 } |
658 } |
634 $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; |
659 $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; |
635 ?> |
660 ?> |
652 } |
677 } |
653 |
678 |
654 /** |
679 /** |
655 * @param WP_Post $post |
680 * @param WP_Post $post |
656 * @param string $att_title |
681 * @param string $att_title |
657 * |
|
658 * @return array |
682 * @return array |
659 */ |
683 */ |
660 private function _get_row_actions( $post, $att_title ) { |
684 private function _get_row_actions( $post, $att_title ) { |
661 $actions = array(); |
685 $actions = array(); |
662 |
686 |
663 if ( $this->detached ) { |
687 if ( $this->detached ) { |
664 if ( current_user_can( 'edit_post', $post->ID ) ) { |
688 if ( current_user_can( 'edit_post', $post->ID ) ) { |
665 $actions['edit'] = sprintf( |
689 $actions['edit'] = sprintf( |
666 '<a href="%s" aria-label="%s">%s</a>', |
690 '<a href="%s" aria-label="%s">%s</a>', |
667 get_edit_post_link( $post->ID ), |
691 get_edit_post_link( $post->ID ), |
668 /* translators: %s: attachment title */ |
692 /* translators: %s: Attachment title. */ |
669 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
693 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
670 __( 'Edit' ) |
694 __( 'Edit' ) |
671 ); |
695 ); |
672 } |
696 } |
673 if ( current_user_can( 'delete_post', $post->ID ) ) { |
697 if ( current_user_can( 'delete_post', $post->ID ) ) { |
674 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
698 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
675 $actions['trash'] = sprintf( |
699 $actions['trash'] = sprintf( |
676 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
700 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
677 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
701 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
678 /* translators: %s: attachment title */ |
702 /* translators: %s: Attachment title. */ |
679 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
703 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
680 _x( 'Trash', 'verb' ) |
704 _x( 'Trash', 'verb' ) |
681 ); |
705 ); |
682 } else { |
706 } else { |
683 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
707 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
684 $actions['delete'] = sprintf( |
708 $actions['delete'] = sprintf( |
685 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
709 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
686 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
710 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
687 $delete_ays, |
711 $delete_ays, |
688 /* translators: %s: attachment title */ |
712 /* translators: %s: Attachment title. */ |
689 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
713 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
690 __( 'Delete Permanently' ) |
714 __( 'Delete Permanently' ) |
691 ); |
715 ); |
692 } |
716 } |
693 } |
717 } |
694 $actions['view'] = sprintf( |
718 $actions['view'] = sprintf( |
695 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
719 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
696 get_permalink( $post->ID ), |
720 get_permalink( $post->ID ), |
697 /* translators: %s: attachment title */ |
721 /* translators: %s: Attachment title. */ |
698 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
722 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
699 __( 'View' ) |
723 __( 'View' ) |
700 ); |
724 ); |
701 |
725 |
702 if ( current_user_can( 'edit_post', $post->ID ) ) { |
726 if ( current_user_can( 'edit_post', $post->ID ) ) { |
703 $actions['attach'] = sprintf( |
727 $actions['attach'] = sprintf( |
704 '<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
728 '<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
705 $post->ID, |
729 $post->ID, |
706 /* translators: %s: attachment title */ |
730 /* translators: %s: Attachment title. */ |
707 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), |
731 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), |
708 __( 'Attach' ) |
732 __( 'Attach' ) |
709 ); |
733 ); |
710 } |
734 } |
711 } else { |
735 } else { |
712 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
736 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
713 $actions['edit'] = sprintf( |
737 $actions['edit'] = sprintf( |
714 '<a href="%s" aria-label="%s">%s</a>', |
738 '<a href="%s" aria-label="%s">%s</a>', |
715 get_edit_post_link( $post->ID ), |
739 get_edit_post_link( $post->ID ), |
716 /* translators: %s: attachment title */ |
740 /* translators: %s: Attachment title. */ |
717 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
741 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
718 __( 'Edit' ) |
742 __( 'Edit' ) |
719 ); |
743 ); |
720 } |
744 } |
721 if ( current_user_can( 'delete_post', $post->ID ) ) { |
745 if ( current_user_can( 'delete_post', $post->ID ) ) { |
722 if ( $this->is_trash ) { |
746 if ( $this->is_trash ) { |
723 $actions['untrash'] = sprintf( |
747 $actions['untrash'] = sprintf( |
724 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
748 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
725 wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), |
749 wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), |
726 /* translators: %s: attachment title */ |
750 /* translators: %s: Attachment title. */ |
727 esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), |
751 esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), |
728 __( 'Restore' ) |
752 __( 'Restore' ) |
729 ); |
753 ); |
730 } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
754 } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
731 $actions['trash'] = sprintf( |
755 $actions['trash'] = sprintf( |
732 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
756 '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
733 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
757 wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
734 /* translators: %s: attachment title */ |
758 /* translators: %s: Attachment title. */ |
735 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
759 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
736 _x( 'Trash', 'verb' ) |
760 _x( 'Trash', 'verb' ) |
737 ); |
761 ); |
738 } |
762 } |
739 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
763 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
740 $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
764 $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
741 $actions['delete'] = sprintf( |
765 $actions['delete'] = sprintf( |
742 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
766 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
743 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
767 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
744 $delete_ays, |
768 $delete_ays, |
745 /* translators: %s: attachment title */ |
769 /* translators: %s: Attachment title. */ |
746 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
770 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
747 __( 'Delete Permanently' ) |
771 __( 'Delete Permanently' ) |
748 ); |
772 ); |
749 } |
773 } |
750 } |
774 } |
751 if ( ! $this->is_trash ) { |
775 if ( ! $this->is_trash ) { |
752 $actions['view'] = sprintf( |
776 $actions['view'] = sprintf( |
753 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
777 '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
754 get_permalink( $post->ID ), |
778 get_permalink( $post->ID ), |
755 /* translators: %s: attachment title */ |
779 /* translators: %s: Attachment title. */ |
756 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
780 esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
757 __( 'View' ) |
781 __( 'View' ) |
758 ); |
782 ); |
759 } |
783 } |
760 } |
784 } |
779 * @since 4.3.0 |
803 * @since 4.3.0 |
780 * |
804 * |
781 * @param object $post Attachment being acted upon. |
805 * @param object $post Attachment being acted upon. |
782 * @param string $column_name Current column name. |
806 * @param string $column_name Current column name. |
783 * @param string $primary Primary column name. |
807 * @param string $primary Primary column name. |
784 * @return string Row actions output for media attachments. |
808 * @return string Row actions output for media attachments, or an empty string |
809 * if the current column is not the primary column. |
|
785 */ |
810 */ |
786 protected function handle_row_actions( $post, $column_name, $primary ) { |
811 protected function handle_row_actions( $post, $column_name, $primary ) { |
787 if ( $primary !== $column_name ) { |
812 if ( $primary !== $column_name ) { |
788 return ''; |
813 return ''; |
789 } |
814 } |
790 |
815 |
791 $att_title = _draft_or_post_title(); |
816 $att_title = _draft_or_post_title(); |
817 |
|
792 return $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); |
818 return $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); |
793 } |
819 } |
794 } |
820 } |