]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/includes/class-wp-media-list-table.php
WordPress 4.3.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-media-list-table.php
1 <?php
2 /**
3  * Media Library List Table class.
4  *
5  * @package WordPress
6  * @subpackage List_Table
7  * @since 3.1.0
8  * @access private
9  */
10 class WP_Media_List_Table extends WP_List_Table {
11
12         private $detached;
13
14         private $is_trash;
15
16         /**
17          * Constructor.
18          *
19          * @since 3.1.0
20          * @access public
21          *
22          * @see WP_List_Table::__construct() for more information on default arguments.
23          *
24          * @param array $args An associative array of arguments.
25          */
26         public function __construct( $args = array() ) {
27                 $this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] );
28
29                 $this->modes = array(
30                         'list' => __( 'List View' ),
31                         'grid' => __( 'Grid View' )
32                 );
33
34                 parent::__construct( array(
35                         'plural' => 'media',
36                         'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
37                 ) );
38         }
39
40         /**
41          *
42          * @return bool
43          */
44         public function ajax_user_can() {
45                 return current_user_can('upload_files');
46         }
47
48         /**
49          *
50          * @global WP_Query $wp_query
51          * @global array    $post_mime_types
52          * @global array    $avail_post_mime_types
53          * @global string   $mode
54          */
55         public function prepare_items() {
56                 global $wp_query, $post_mime_types, $avail_post_mime_types, $mode;
57
58                 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST );
59
60                 $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' == $_REQUEST['attachment-filter'];
61
62                 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
63
64                 $this->set_pagination_args( array(
65                         'total_items' => $wp_query->found_posts,
66                         'total_pages' => $wp_query->max_num_pages,
67                         'per_page' => $wp_query->query_vars['posts_per_page'],
68                 ) );
69         }
70
71         /**
72          *
73          * @global wpdb  $wpdb
74          * @global array $post_mime_types
75          * @global array $avail_post_mime_types
76          * @return array
77          */
78         protected function get_views() {
79                 global $wpdb, $post_mime_types, $avail_post_mime_types;
80
81                 $type_links = array();
82                 $_num_posts = (array) wp_count_attachments();
83                 $_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
84                 $total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" );
85                 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
86                 $num_posts = array();
87                 foreach ( $matches as $type => $reals ) {
88                         foreach ( $reals as $real ) {
89                                 $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
90                         }
91                 }
92                 $selected = empty( $_GET['attachment-filter'] ) ? ' selected="selected"' : '';
93                 $type_links['all'] = "<option value=''$selected>" . sprintf( _nx( 'All (%s)', 'All (%s)', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</option>';
94                 foreach ( $post_mime_types as $mime_type => $label ) {
95                         if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
96                                 continue;
97
98                         $selected = '';
99                         if ( !empty( $_GET['attachment-filter'] ) && strpos( $_GET['attachment-filter'], 'post_mime_type:' ) === 0 && wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $_GET['attachment-filter'] ) ) )
100                                 $selected = ' selected="selected"';
101                         if ( !empty( $num_posts[$mime_type] ) )
102                                 $type_links[$mime_type] = '<option value="post_mime_type:' . esc_attr( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
103                 }
104                 $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</option>';
105
106                 if ( !empty($_num_posts['trash']) )
107                         $type_links['trash'] = '<option value="trash"' . ( (isset($_GET['attachment-filter']) && $_GET['attachment-filter'] == 'trash' ) ? ' selected="selected"' : '') . '>' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</option>';
108
109                 return $type_links;
110         }
111
112         /**
113          *
114          * @return array
115          */
116         protected function get_bulk_actions() {
117                 $actions = array();
118                 if ( MEDIA_TRASH ) {
119                         if ( $this->is_trash ) {
120                                 $actions['untrash'] = __( 'Restore' );
121                                 $actions['delete'] = __( 'Delete Permanently' );
122                         } else {
123                                 $actions['trash'] = __( 'Trash' );
124                         }
125                 } else {
126                         $actions['delete'] = __( 'Delete Permanently' );
127                 }
128
129                 if ( $this->detached )
130                         $actions['attach'] = __( 'Attach to a post' );
131
132                 return $actions;
133         }
134
135         /**
136          * @param string $which
137          */
138         protected function extra_tablenav( $which ) {
139                 if ( 'bar' !== $which ) {
140                         return;
141                 }
142 ?>
143                 <div class="actions">
144 <?php
145                 if ( ! is_singular() ) {
146                         if ( ! $this->is_trash ) {
147                                 $this->months_dropdown( 'attachment' );
148                         }
149
150                         /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
151                         do_action( 'restrict_manage_posts' );
152                         submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
153                 }
154
155                 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
156                         submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
157                 } ?>
158                 </div>
159 <?php
160         }
161
162         /**
163          *
164          * @return string
165          */
166         public function current_action() {
167                 if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
168                         return 'attach';
169
170                 if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) )
171                         return 'detach';
172
173                 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
174                         return 'delete_all';
175
176                 return parent::current_action();
177         }
178
179         /**
180          *
181          * @return bool
182          */
183         public function has_items() {
184                 return have_posts();
185         }
186
187         /**
188          * @access public
189          */
190         public function no_items() {
191                 _e( 'No media attachments found.' );
192         }
193
194         /**
195          * Override parent views so we can use the filter bar display.
196          *
197          * @global string $mode
198          */
199         public function views() {
200                 global $mode;
201
202                 $views = $this->get_views();
203 ?>
204 <div class="wp-filter">
205         <div class="filter-items">
206                 <?php $this->view_switcher( $mode ); ?>
207
208                 <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
209                 <select class="attachment-filters" name="attachment-filter" id="attachment-filter">
210                         <?php
211                         if ( ! empty( $views ) ) {
212                                 foreach ( $views as $class => $view ) {
213                                         echo "\t$view\n";
214                                 }
215                         }
216                         ?>
217                 </select>
218
219 <?php
220                 $this->extra_tablenav( 'bar' );
221
222                 /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
223                 $views = apply_filters( "views_{$this->screen->id}", array() );
224
225                 // Back compat for pre-4.0 view links.
226                 if ( ! empty( $views ) ) {
227                         echo '<ul class="filter-links">';
228                         foreach ( $views as $class => $view ) {
229                                 echo "<li class='$class'>$view</li>";
230                         }
231                         echo '</ul>';
232                 }
233 ?>
234         </div>
235
236         <div class="search-form">
237                 <label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label>
238                 <input type="search" placeholder="<?php esc_attr_e( 'Search' ) ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>
239         </div>
240         <?php
241         }
242
243         /**
244          *
245          * @return array
246          */
247         public function get_columns() {
248                 $posts_columns = array();
249                 $posts_columns['cb'] = '<input type="checkbox" />';
250                 /* translators: column name */
251                 $posts_columns['title'] = _x( 'File', 'column name' );
252                 $posts_columns['author'] = __( 'Author' );
253
254                 $taxonomies = get_taxonomies_for_attachments( 'objects' );
255                 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
256
257                 /**
258                  * Filter the taxonomy columns for attachments in the Media list table.
259                  *
260                  * @since 3.5.0
261                  *
262                  * @param array  $taxonomies An array of registered taxonomies to show for attachments.
263                  * @param string $post_type  The post type. Default 'attachment'.
264                  */
265                 $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' );
266                 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
267
268                 foreach ( $taxonomies as $taxonomy ) {
269                         if ( 'category' == $taxonomy )
270                                 $column_key = 'categories';
271                         elseif ( 'post_tag' == $taxonomy )
272                                 $column_key = 'tags';
273                         else
274                                 $column_key = 'taxonomy-' . $taxonomy;
275
276                         $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
277                 }
278
279                 /* translators: column name */
280                 if ( !$this->detached ) {
281                         $posts_columns['parent'] = _x( 'Uploaded to', 'column name' );
282                         if ( post_type_supports( 'attachment', 'comments' ) )
283                                 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
284                 }
285                 /* translators: column name */
286                 $posts_columns['date'] = _x( 'Date', 'column name' );
287                 /**
288                  * Filter the Media list table columns.
289                  *
290                  * @since 2.5.0
291                  *
292                  * @param array $posts_columns An array of columns displayed in the Media list table.
293                  * @param bool  $detached      Whether the list table contains media not attached
294                  *                             to any posts. Default true.
295                  */
296                 return apply_filters( 'manage_media_columns', $posts_columns, $this->detached );
297         }
298
299         /**
300          *
301          * @return array
302          */
303         protected function get_sortable_columns() {
304                 return array(
305                         'title'    => 'title',
306                         'author'   => 'author',
307                         'parent'   => 'parent',
308                         'comments' => 'comment_count',
309                         'date'     => array( 'date', true ),
310                 );
311         }
312
313         /**
314          * Handles the checkbox column output.
315          *
316          * @since 4.3.0
317          * @access public
318          *
319          * @param WP_Post $post The current WP_Post object.
320          */
321         public function column_cb( $post ) {
322                 if ( current_user_can( 'edit_post', $post->ID ) ) { ?>
323                         <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"><?php
324                                 echo sprintf( __( 'Select %s' ), _draft_or_post_title() );
325                         ?></label>
326                         <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
327                 <?php }
328         }
329
330         /**
331          * Handles the title column output.
332          *
333          * @since 4.3.0
334          * @access public
335          *
336          * @param WP_Post $post The current WP_Post object.
337          */
338         public function column_title( $post ) {
339                 list( $mime ) = explode( '/', $post->post_mime_type );
340
341                 $title = _draft_or_post_title();
342                 $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
343                 $link_start = $link_end = '';
344
345                 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
346                         $link_start = '<a href="' . get_edit_post_link( $post->ID ) . '">';
347                         $link_end = '</a>';
348                 }
349
350                 $class = $thumb ? ' class="has-media-icon"' : '';
351
352                 ?>
353                 <strong<?php echo $class; ?>>
354                         <?php echo $link_start; ?>
355                                 <?php if ( $thumb ) : ?>
356                                 <span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span>
357                                 <?php endif; ?>
358
359                                 <span aria-hidden="true"><?php echo $title; ?></span>
360                                 <span class="screen-reader-text"><?php printf( __( 'Edit &#8220;%s&#8221;' ), $title ); ?></span>
361                         <?php echo $link_end; ?>
362                         <?php _media_states( $post ); ?>
363                 </strong>
364                 <p class="filename"><span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span><?php echo wp_basename( $post->guid ); ?></p>
365                 <?php
366         }
367
368         /**
369          * Handles the author column output.
370          *
371          * @since 4.3.0
372          * @access public
373          *
374          * @param WP_Post $post The current WP_Post object.
375          */
376         public function column_author( $post ) {
377                 printf( '<a href="%s">%s</a>',
378                         esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
379                         get_the_author()
380                 );
381         }
382
383         /**
384          * Handles the description column output.
385          *
386          * @since 4.3.0
387          * @access public
388          *
389          * @param WP_Post $post The current WP_Post object.
390          */
391         public function column_desc( $post ) {
392                 echo has_excerpt() ? $post->post_excerpt : '';
393         }
394
395         /**
396          * Handles the date column output.
397          *
398          * @since 4.3.0
399          * @access public
400          *
401          * @param WP_Post $post The current WP_Post object.
402          */
403         public function column_date( $post ) {
404                 if ( '0000-00-00 00:00:00' == $post->post_date ) {
405                         $h_time = __( 'Unpublished' );
406                 } else {
407                         $m_time = $post->post_date;
408                         $time = get_post_time( 'G', true, $post, false );
409                         if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
410                                 if ( $t_diff < 0 ) {
411                                         $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
412                                 } else {
413                                         $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
414                                 }
415                         } else {
416                                 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
417                         }
418                 }
419
420                 echo $h_time;
421         }
422
423         /**
424          * Handles the parent column output.
425          *
426          * @since 4.3.0
427          * @access public
428          *
429          * @param WP_Post $post The current WP_Post object.
430          */
431         public function column_parent( $post ) {
432                 $user_can_edit = current_user_can( 'edit_post', $post->ID );
433
434                 if ( $post->post_parent > 0 ) {
435                         $parent = get_post( $post->post_parent );
436                 } else {
437                         $parent = false;
438                 }
439
440                 if ( $parent ) {
441                         $title = _draft_or_post_title( $post->post_parent );
442                         $parent_type = get_post_type_object( $parent->post_type );
443 ?>
444                         <strong>
445                         <?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
446                                 <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
447                                         <?php echo $title ?></a><?php
448                         } else {
449                                 echo $title;
450                         } ?></strong>,
451                         <?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
452                         <?php
453                         if ( $user_can_edit ):
454                                 $detach_url = add_query_arg( array(
455                                         'parent_post_id' => $post->post_parent,
456                                         'media[]' => $post->ID,
457                                         '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
458                                 ), 'upload.php' ); ?>
459                         <a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
460                         <?php endif;
461                 } else {
462                         _e( '(Unattached)' ); ?><br />
463                         <?php if ( $user_can_edit ) { ?>
464                                 <a class="hide-if-no-js"
465                                         onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
466                                         href="#the-list">
467                                         <?php _e( 'Attach' ); ?></a>
468                         <?php }
469                 }
470         }
471
472         /**
473          * Handles the comments column output.
474          *
475          * @since 4.3.0
476          * @access public
477          *
478          * @param WP_Post $post The current WP_Post object.
479          */
480         public function column_comments( $post ) {
481                 echo '<div class="post-com-count-wrapper">';
482
483                 $pending_comments = get_pending_comments_num( $post->ID );
484                 $this->comments_bubble( $post->ID, $pending_comments );
485
486                 echo '</div>';
487         }
488
489         /**
490          * Handles output for the default column.
491          *
492          * @since 4.3.0
493          * @access public
494          *
495          * @param WP_Post $post        The current WP_Post object.
496          * @param string  $column_name Current column name.
497          */
498         public function column_default( $post, $column_name ) {
499                 if ( 'categories' == $column_name ) {
500                         $taxonomy = 'category';
501                 } elseif ( 'tags' == $column_name ) {
502                         $taxonomy = 'post_tag';
503                 } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
504                         $taxonomy = substr( $column_name, 9 );
505                 } else {
506                         $taxonomy = false;
507                 }
508
509                 if ( $taxonomy ) {
510                         $terms = get_the_terms( $post->ID, $taxonomy );
511                         if ( is_array( $terms ) ) {
512                                 $out = array();
513                                 foreach ( $terms as $t ) {
514                                         $posts_in_term_qv = array();
515                                         $posts_in_term_qv['taxonomy'] = $taxonomy;
516                                         $posts_in_term_qv['term'] = $t->slug;
517
518                                         $out[] = sprintf( '<a href="%s">%s</a>',
519                                                 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
520                                                 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
521                                         );
522                                 }
523                                 /* translators: used between list items, there is a space after the comma */
524                                 echo join( __( ', ' ), $out );
525                         } else {
526                                 echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>';
527                         }
528
529                         return;
530                 }
531
532                 /**
533                  * Fires for each custom column in the Media list table.
534                  *
535                  * Custom columns are registered using the {@see 'manage_media_columns'} filter.
536                  *
537                  * @since 2.5.0
538                  *
539                  * @param string $column_name Name of the custom column.
540                  * @param int    $post_id     Attachment ID.
541                  */
542                 do_action( 'manage_media_custom_column', $column_name, $post->ID );
543         }
544
545         /**
546          *
547          * @global WP_Post $post
548          */
549         public function display_rows() {
550                 global $post;
551
552                 add_filter( 'the_title','esc_html' );
553
554                 while ( have_posts() ) : the_post();
555                         if (
556                                 ( $this->is_trash && $post->post_status != 'trash' )
557                                 || ( ! $this->is_trash && $post->post_status == 'trash' )
558                         ) {
559                                 continue;
560                         }
561                         $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other';
562                 ?>
563                         <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
564                                 <?php $this->single_row_columns( $post ); ?>
565                         </tr>
566                 <?php
567                 endwhile;
568         }
569
570         /**
571          * Gets the name of the default primary column.
572          *
573          * @since 4.3.0
574          * @access protected
575          *
576          * @return string Name of the default primary column, in this case, 'title'.
577          */
578         protected function get_default_primary_column_name() {
579                 return 'title';
580         }
581
582         /**
583          * @param WP_Post $post
584          * @param string  $att_title
585          *
586          * @return array
587          */
588         private function _get_row_actions( $post, $att_title ) {
589                 $actions = array();
590
591                 if ( $this->detached ) {
592                         if ( current_user_can( 'edit_post', $post->ID ) )
593                                 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( 'Edit' ) . '</a>';
594                         if ( current_user_can( 'delete_post', $post->ID ) )
595                                 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
596                                         $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
597                                 } else {
598                                         $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
599                                         $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
600                                 }
601                         $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
602                         if ( current_user_can( 'edit_post', $post->ID ) )
603                                 $actions['attach'] = '<a href="#the-list" onclick="findPosts.open( \'media[]\',\''.$post->ID.'\' );return false;" class="hide-if-no-js">'.__( 'Attach' ).'</a>';
604                 }
605                 else {
606                         if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash )
607                                 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( 'Edit' ) . '</a>';
608                         if ( current_user_can( 'delete_post', $post->ID ) ) {
609                                 if ( $this->is_trash )
610                                         $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
611                                 elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
612                                         $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
613                                 if ( $this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) {
614                                         $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
615                                         $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
616                                 }
617                         }
618                         if ( !$this->is_trash ) {
619                                 $title =_draft_or_post_title( $post->post_parent );
620                                 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
621                         }
622                 }
623
624                 /**
625                  * Filter the action links for each attachment in the Media list table.
626                  *
627                  * @since 2.8.0
628                  *
629                  * @param array   $actions  An array of action links for each attachment.
630                  *                          Default 'Edit', 'Delete Permanently', 'View'.
631                  * @param WP_Post $post     WP_Post object for the current attachment.
632                  * @param bool    $detached Whether the list table contains media not attached
633                  *                          to any posts. Default true.
634                  */
635                 return apply_filters( 'media_row_actions', $actions, $post, $this->detached );
636         }
637
638         /**
639          * Generates and displays row action links.
640          *
641          * @since 4.3.0
642          * @access protected
643          *
644          * @param object $post        Attachment being acted upon.
645          * @param string $column_name Current column name.
646          * @param string $primary     Primary column name.
647          * @return string Row actions output for media attachments.
648          */
649         protected function handle_row_actions( $post, $column_name, $primary ) {
650                 if ( $primary !== $column_name ) {
651                         return '';
652                 }
653
654                 $att_title = _draft_or_post_title();
655                 return $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
656         }
657 }