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( array( |
48 parent::__construct( |
49 'plural' => 'media', |
49 array( |
50 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
50 'plural' => 'media', |
51 ) ); |
51 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
52 } |
52 ) |
53 |
53 ); |
54 /** |
54 } |
55 * |
55 |
|
56 /** |
56 * @return bool |
57 * @return bool |
57 */ |
58 */ |
58 public function ajax_user_can() { |
59 public function ajax_user_can() { |
59 return current_user_can('upload_files'); |
60 return current_user_can( 'upload_files' ); |
60 } |
61 } |
61 |
62 |
62 /** |
63 /** |
63 * |
|
64 * @global WP_Query $wp_query |
64 * @global WP_Query $wp_query |
65 * @global array $post_mime_types |
65 * @global array $post_mime_types |
66 * @global array $avail_post_mime_types |
66 * @global array $avail_post_mime_types |
67 * @global string $mode |
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 $wp_query, $post_mime_types, $avail_post_mime_types, $mode; |
71 |
71 |
72 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); |
72 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); |
73 |
73 |
74 $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; |
74 $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; |
75 |
75 |
76 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
76 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
77 |
77 |
78 $this->set_pagination_args( array( |
78 $this->set_pagination_args( |
79 'total_items' => $wp_query->found_posts, |
79 array( |
80 'total_pages' => $wp_query->max_num_pages, |
80 'total_items' => $wp_query->found_posts, |
81 'per_page' => $wp_query->query_vars['posts_per_page'], |
81 'total_pages' => $wp_query->max_num_pages, |
82 ) ); |
82 'per_page' => $wp_query->query_vars['posts_per_page'], |
|
83 ) |
|
84 ); |
83 } |
85 } |
84 |
86 |
85 /** |
87 /** |
86 * @global array $post_mime_types |
88 * @global array $post_mime_types |
87 * @global array $avail_post_mime_types |
89 * @global array $avail_post_mime_types |
110 wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ), |
112 wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ), |
111 true, |
113 true, |
112 false |
114 false |
113 ); |
115 ); |
114 |
116 |
115 $type_links[$mime_type] = sprintf( |
117 $type_links[ $mime_type ] = sprintf( |
116 '<option value="post_mime_type:%s"%s>%s</option>', |
118 '<option value="post_mime_type:%s"%s>%s</option>', |
117 esc_attr( $mime_type ), |
119 esc_attr( $mime_type ), |
118 $selected, |
120 $selected, |
119 $label[0] |
121 $label[0] |
120 ); |
122 ); |
126 '<option value="mine"%s>%s</option>', |
128 '<option value="mine"%s>%s</option>', |
127 selected( 'mine' === $filter, true, false ), |
129 selected( 'mine' === $filter, true, false ), |
128 _x( 'Mine', 'media items' ) |
130 _x( 'Mine', 'media items' ) |
129 ); |
131 ); |
130 |
132 |
131 if ( $this->is_trash || ( defined( 'MEDIA_TRASH') && MEDIA_TRASH ) ) { |
133 if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) { |
132 $type_links['trash'] = sprintf( |
134 $type_links['trash'] = sprintf( |
133 '<option value="trash"%s>%s</option>', |
135 '<option value="trash"%s>%s</option>', |
134 selected( 'trash' === $filter, true, false ), |
136 selected( 'trash' === $filter, true, false ), |
135 _x( 'Trash', 'attachment filter' ) |
137 _x( 'Trash', 'attachment filter' ) |
136 ); |
138 ); |
138 |
140 |
139 return $type_links; |
141 return $type_links; |
140 } |
142 } |
141 |
143 |
142 /** |
144 /** |
143 * |
|
144 * @return array |
145 * @return array |
145 */ |
146 */ |
146 protected function get_bulk_actions() { |
147 protected function get_bulk_actions() { |
147 $actions = array(); |
148 $actions = array(); |
148 if ( MEDIA_TRASH ) { |
149 if ( MEDIA_TRASH ) { |
149 if ( $this->is_trash ) { |
150 if ( $this->is_trash ) { |
150 $actions['untrash'] = __( 'Restore' ); |
151 $actions['untrash'] = __( 'Restore' ); |
151 $actions['delete'] = __( 'Delete Permanently' ); |
152 $actions['delete'] = __( 'Delete Permanently' ); |
152 } else { |
153 } else { |
153 $actions['trash'] = _x( 'Trash', 'verb' ); |
154 $actions['trash'] = __( 'Move to Trash' ); |
154 } |
155 } |
155 } else { |
156 } else { |
156 $actions['delete'] = __( 'Delete Permanently' ); |
157 $actions['delete'] = __( 'Delete Permanently' ); |
157 } |
158 } |
158 |
159 |
159 if ( $this->detached ) |
160 if ( $this->detached ) { |
160 $actions['attach'] = __( 'Attach' ); |
161 $actions['attach'] = __( 'Attach' ); |
|
162 } |
161 |
163 |
162 return $actions; |
164 return $actions; |
163 } |
165 } |
164 |
166 |
165 /** |
167 /** |
183 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
185 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
184 } |
186 } |
185 |
187 |
186 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { |
188 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { |
187 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
189 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
188 } ?> |
190 } |
|
191 ?> |
189 </div> |
192 </div> |
190 <?php |
193 <?php |
191 } |
194 } |
192 |
195 |
193 /** |
196 /** |
194 * |
|
195 * @return string |
197 * @return string |
196 */ |
198 */ |
197 public function current_action() { |
199 public function current_action() { |
198 if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) |
200 if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) { |
199 return 'attach'; |
201 return 'attach'; |
200 |
202 } |
201 if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) |
203 |
|
204 if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) { |
202 return 'detach'; |
205 return 'detach'; |
203 |
206 } |
204 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
207 |
|
208 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { |
205 return 'delete_all'; |
209 return 'delete_all'; |
|
210 } |
206 |
211 |
207 return parent::current_action(); |
212 return parent::current_action(); |
208 } |
213 } |
209 |
214 |
210 /** |
215 /** |
211 * |
|
212 * @return bool |
216 * @return bool |
213 */ |
217 */ |
214 public function has_items() { |
218 public function has_items() { |
215 return have_posts(); |
219 return have_posts(); |
216 } |
220 } |
230 global $mode; |
234 global $mode; |
231 |
235 |
232 $views = $this->get_views(); |
236 $views = $this->get_views(); |
233 |
237 |
234 $this->screen->render_screen_reader_content( 'heading_views' ); |
238 $this->screen->render_screen_reader_content( 'heading_views' ); |
235 ?> |
239 ?> |
236 <div class="wp-filter"> |
240 <div class="wp-filter"> |
237 <div class="filter-items"> |
241 <div class="filter-items"> |
238 <?php $this->view_switcher( $mode ); ?> |
242 <?php $this->view_switcher( $mode ); ?> |
239 |
243 |
240 <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label> |
244 <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label> |
260 foreach ( $views as $class => $view ) { |
264 foreach ( $views as $class => $view ) { |
261 echo "<li class='$class'>$view</li>"; |
265 echo "<li class='$class'>$view</li>"; |
262 } |
266 } |
263 echo '</ul>'; |
267 echo '</ul>'; |
264 } |
268 } |
265 ?> |
269 ?> |
266 </div> |
270 </div> |
267 |
271 |
268 <div class="search-form"> |
272 <div class="search-form"> |
269 <label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label> |
273 <label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label> |
270 <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> |
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> |
271 </div> |
275 </div> |
272 <?php |
276 <?php |
273 } |
277 } |
274 |
278 |
275 /** |
279 /** |
276 * |
|
277 * @return array |
280 * @return array |
278 */ |
281 */ |
279 public function get_columns() { |
282 public function get_columns() { |
280 $posts_columns = array(); |
283 $posts_columns = array(); |
281 $posts_columns['cb'] = '<input type="checkbox" />'; |
284 $posts_columns['cb'] = '<input type="checkbox" />'; |
282 /* translators: column name */ |
285 /* translators: column name */ |
283 $posts_columns['title'] = _x( 'File', 'column name' ); |
286 $posts_columns['title'] = _x( 'File', 'column name' ); |
284 $posts_columns['author'] = __( 'Author' ); |
287 $posts_columns['author'] = __( 'Author' ); |
285 |
288 |
286 $taxonomies = get_taxonomies_for_attachments( 'objects' ); |
289 $taxonomies = get_taxonomies_for_attachments( 'objects' ); |
287 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
290 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
288 |
291 |
289 /** |
292 /** |
290 * Filters the taxonomy columns for attachments in the Media list table. |
293 * Filters the taxonomy columns for attachments in the Media list table. |
291 * |
294 * |
292 * @since 3.5.0 |
295 * @since 3.5.0 |
293 * |
296 * |
294 * @param array $taxonomies An array of registered taxonomies to show for attachments. |
297 * @param string[] $taxonomies An array of registered taxonomy names to show for attachments. |
295 * @param string $post_type The post type. Default 'attachment'. |
298 * @param string $post_type The post type. Default 'attachment'. |
296 */ |
299 */ |
297 $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' ); |
300 $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' ); |
298 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
301 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
299 |
302 |
300 foreach ( $taxonomies as $taxonomy ) { |
303 foreach ( $taxonomies as $taxonomy ) { |
307 } |
310 } |
308 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
311 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
309 } |
312 } |
310 |
313 |
311 /* translators: column name */ |
314 /* translators: column name */ |
312 if ( !$this->detached ) { |
315 if ( ! $this->detached ) { |
313 $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
316 $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
314 if ( post_type_supports( 'attachment', 'comments' ) ) |
317 if ( post_type_supports( 'attachment', 'comments' ) ) { |
315 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
318 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
319 } |
316 } |
320 } |
317 /* translators: column name */ |
321 /* translators: column name */ |
318 $posts_columns['date'] = _x( 'Date', 'column name' ); |
322 $posts_columns['date'] = _x( 'Date', 'column name' ); |
319 /** |
323 /** |
320 * Filters the Media list table columns. |
324 * Filters the Media list table columns. |
321 * |
325 * |
322 * @since 2.5.0 |
326 * @since 2.5.0 |
323 * |
327 * |
324 * @param array $posts_columns An array of columns displayed in the Media list table. |
328 * @param string[] $posts_columns An array of columns displayed in the Media list table. |
325 * @param bool $detached Whether the list table contains media not attached |
329 * @param bool $detached Whether the list table contains media not attached |
326 * to any posts. Default true. |
330 * to any posts. Default true. |
327 */ |
331 */ |
328 return apply_filters( 'manage_media_columns', $posts_columns, $this->detached ); |
332 return apply_filters( 'manage_media_columns', $posts_columns, $this->detached ); |
329 } |
333 } |
330 |
334 |
331 /** |
335 /** |
332 * |
|
333 * @return array |
336 * @return array |
334 */ |
337 */ |
335 protected function get_sortable_columns() { |
338 protected function get_sortable_columns() { |
336 return array( |
339 return array( |
337 'title' => 'title', |
340 'title' => 'title', |
348 * @since 4.3.0 |
351 * @since 4.3.0 |
349 * |
352 * |
350 * @param WP_Post $post The current WP_Post object. |
353 * @param WP_Post $post The current WP_Post object. |
351 */ |
354 */ |
352 public function column_cb( $post ) { |
355 public function column_cb( $post ) { |
353 if ( current_user_can( 'edit_post', $post->ID ) ) { ?> |
356 if ( current_user_can( 'edit_post', $post->ID ) ) { |
354 <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"><?php |
357 ?> |
355 echo sprintf( __( 'Select %s' ), _draft_or_post_title() ); |
358 <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"> |
356 ?></label> |
359 <?php |
|
360 echo sprintf( __( 'Select %s' ), _draft_or_post_title() ); |
|
361 ?> |
|
362 </label> |
357 <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> |
363 <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> |
358 <?php } |
364 <?php |
|
365 } |
359 } |
366 } |
360 |
367 |
361 /** |
368 /** |
362 * Handles the title column output. |
369 * Handles the title column output. |
363 * |
370 * |
366 * @param WP_Post $post The current WP_Post object. |
373 * @param WP_Post $post The current WP_Post object. |
367 */ |
374 */ |
368 public function column_title( $post ) { |
375 public function column_title( $post ) { |
369 list( $mime ) = explode( '/', $post->post_mime_type ); |
376 list( $mime ) = explode( '/', $post->post_mime_type ); |
370 |
377 |
371 $title = _draft_or_post_title(); |
378 $title = _draft_or_post_title(); |
372 $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); |
379 $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); |
373 $link_start = $link_end = ''; |
380 $link_start = $link_end = ''; |
374 |
381 |
375 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
382 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
376 $link_start = sprintf( |
383 $link_start = sprintf( |
377 '<a href="%s" aria-label="%s">', |
384 '<a href="%s" aria-label="%s">', |
439 public function column_date( $post ) { |
449 public function column_date( $post ) { |
440 if ( '0000-00-00 00:00:00' === $post->post_date ) { |
450 if ( '0000-00-00 00:00:00' === $post->post_date ) { |
441 $h_time = __( 'Unpublished' ); |
451 $h_time = __( 'Unpublished' ); |
442 } else { |
452 } else { |
443 $m_time = $post->post_date; |
453 $m_time = $post->post_date; |
444 $time = get_post_time( 'G', true, $post, false ); |
454 $time = get_post_time( 'G', true, $post, false ); |
445 if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) { |
455 if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) { |
446 if ( $t_diff < 0 ) { |
456 if ( $t_diff < 0 ) { |
447 $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); |
457 $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); |
448 } else { |
458 } else { |
449 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
459 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
471 } else { |
481 } else { |
472 $parent = false; |
482 $parent = false; |
473 } |
483 } |
474 |
484 |
475 if ( $parent ) { |
485 if ( $parent ) { |
476 $title = _draft_or_post_title( $post->post_parent ); |
486 $title = _draft_or_post_title( $post->post_parent ); |
477 $parent_type = get_post_type_object( $parent->post_type ); |
487 $parent_type = get_post_type_object( $parent->post_type ); |
478 |
488 |
479 if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { |
489 if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { |
480 ?> |
490 ?> |
481 <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"> |
491 <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"> |
482 <?php echo $title ?></a></strong><?php |
492 <?php echo $title; ?></a></strong> |
|
493 <?php |
483 } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { |
494 } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { |
484 ?> |
495 ?> |
485 <strong><?php echo $title ?></strong><?php |
496 <strong><?php echo $title; ?></strong> |
|
497 <?php |
486 } else { |
498 } else { |
487 _e( '(Private post)' ); |
499 _e( '(Private post)' ); |
488 } |
500 } |
489 |
501 |
490 if ( $user_can_edit ): |
502 if ( $user_can_edit ) : |
491 $detach_url = add_query_arg( array( |
503 $detach_url = add_query_arg( |
492 'parent_post_id' => $post->post_parent, |
504 array( |
493 'media[]' => $post->ID, |
505 'parent_post_id' => $post->post_parent, |
494 '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ) |
506 'media[]' => $post->ID, |
495 ), 'upload.php' ); |
507 '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ), |
|
508 ), |
|
509 'upload.php' |
|
510 ); |
496 printf( |
511 printf( |
497 '<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>', |
512 '<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>', |
498 $detach_url, |
513 $detach_url, |
499 /* translators: %s: title of the post the attachment is attached to */ |
514 /* translators: %s: title of the post the attachment is attached to */ |
500 esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), |
515 esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), |
501 __( 'Detach' ) |
516 __( 'Detach' ) |
502 ); |
517 ); |
503 endif; |
518 endif; |
504 } else { |
519 } else { |
505 _e( '(Unattached)' ); ?> |
520 _e( '(Unattached)' ); |
506 <?php if ( $user_can_edit ) { |
521 ?> |
|
522 <?php |
|
523 if ( $user_can_edit ) { |
507 $title = _draft_or_post_title( $post->post_parent ); |
524 $title = _draft_or_post_title( $post->post_parent ); |
508 printf( |
525 printf( |
509 '<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>', |
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>', |
510 $post->ID, |
527 $post->ID, |
511 /* translators: %s: attachment title */ |
528 /* translators: %s: attachment title */ |
559 if ( $taxonomy ) { |
576 if ( $taxonomy ) { |
560 $terms = get_the_terms( $post->ID, $taxonomy ); |
577 $terms = get_the_terms( $post->ID, $taxonomy ); |
561 if ( is_array( $terms ) ) { |
578 if ( is_array( $terms ) ) { |
562 $out = array(); |
579 $out = array(); |
563 foreach ( $terms as $t ) { |
580 foreach ( $terms as $t ) { |
564 $posts_in_term_qv = array(); |
581 $posts_in_term_qv = array(); |
565 $posts_in_term_qv['taxonomy'] = $taxonomy; |
582 $posts_in_term_qv['taxonomy'] = $taxonomy; |
566 $posts_in_term_qv['term'] = $t->slug; |
583 $posts_in_term_qv['term'] = $t->slug; |
567 |
584 |
568 $out[] = sprintf( '<a href="%s">%s</a>', |
585 $out[] = sprintf( |
|
586 '<a href="%s">%s</a>', |
569 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
587 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
570 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
588 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
571 ); |
589 ); |
572 } |
590 } |
573 /* translators: used between list items, there is a space after the comma */ |
591 /* translators: used between list items, there is a space after the comma */ |
591 */ |
609 */ |
592 do_action( 'manage_media_custom_column', $column_name, $post->ID ); |
610 do_action( 'manage_media_custom_column', $column_name, $post->ID ); |
593 } |
611 } |
594 |
612 |
595 /** |
613 /** |
596 * |
|
597 * @global WP_Post $post |
614 * @global WP_Post $post |
598 */ |
615 */ |
599 public function display_rows() { |
616 public function display_rows() { |
600 global $post, $wp_query; |
617 global $post, $wp_query; |
601 |
618 |
602 $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); |
619 $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); |
603 reset( $wp_query->posts ); |
620 reset( $wp_query->posts ); |
604 |
621 |
605 $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
622 $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
606 |
623 |
607 add_filter( 'the_title','esc_html' ); |
624 add_filter( 'the_title', 'esc_html' ); |
608 |
625 |
609 while ( have_posts() ) : the_post(); |
626 while ( have_posts() ) : |
|
627 the_post(); |
610 if ( |
628 if ( |
611 ( $this->is_trash && $post->post_status != 'trash' ) |
629 ( $this->is_trash && $post->post_status != 'trash' ) |
612 || ( ! $this->is_trash && $post->post_status === 'trash' ) |
630 || ( ! $this->is_trash && $post->post_status === 'trash' ) |
613 ) { |
631 ) { |
614 continue; |
632 continue; |
615 } |
633 } |
616 $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; |
634 $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; |
617 ?> |
635 ?> |
618 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> |
636 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> |
619 <?php $this->single_row_columns( $post ); ?> |
637 <?php $this->single_row_columns( $post ); ?> |
620 </tr> |
638 </tr> |
621 <?php |
639 <?php |
622 endwhile; |
640 endwhile; |
623 } |
641 } |
624 |
642 |
625 /** |
643 /** |
626 * Gets the name of the default primary column. |
644 * Gets the name of the default primary column. |
660 /* translators: %s: attachment title */ |
678 /* translators: %s: attachment title */ |
661 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
679 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
662 _x( 'Trash', 'verb' ) |
680 _x( 'Trash', 'verb' ) |
663 ); |
681 ); |
664 } else { |
682 } else { |
665 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
683 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
666 $actions['delete'] = sprintf( |
684 $actions['delete'] = sprintf( |
667 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
685 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
668 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
686 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
669 $delete_ays, |
687 $delete_ays, |
670 /* translators: %s: attachment title */ |
688 /* translators: %s: attachment title */ |
688 /* translators: %s: attachment title */ |
706 /* translators: %s: attachment title */ |
689 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), |
707 esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), |
690 __( 'Attach' ) |
708 __( 'Attach' ) |
691 ); |
709 ); |
692 } |
710 } |
693 } |
711 } else { |
694 else { |
712 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
695 if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) { |
|
696 $actions['edit'] = sprintf( |
713 $actions['edit'] = sprintf( |
697 '<a href="%s" aria-label="%s">%s</a>', |
714 '<a href="%s" aria-label="%s">%s</a>', |
698 get_edit_post_link( $post->ID ), |
715 get_edit_post_link( $post->ID ), |
699 /* translators: %s: attachment title */ |
716 /* translators: %s: attachment title */ |
700 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
717 esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
718 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
735 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
719 _x( 'Trash', 'verb' ) |
736 _x( 'Trash', 'verb' ) |
720 ); |
737 ); |
721 } |
738 } |
722 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
739 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
723 $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
740 $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
724 $actions['delete'] = sprintf( |
741 $actions['delete'] = sprintf( |
725 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
742 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
726 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
743 wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
727 $delete_ays, |
744 $delete_ays, |
728 /* translators: %s: attachment title */ |
745 /* translators: %s: attachment title */ |
745 /** |
762 /** |
746 * Filters the action links for each attachment in the Media list table. |
763 * Filters the action links for each attachment in the Media list table. |
747 * |
764 * |
748 * @since 2.8.0 |
765 * @since 2.8.0 |
749 * |
766 * |
750 * @param array $actions An array of action links for each attachment. |
767 * @param string[] $actions An array of action links for each attachment. |
751 * Default 'Edit', 'Delete Permanently', 'View'. |
768 * Default 'Edit', 'Delete Permanently', 'View'. |
752 * @param WP_Post $post WP_Post object for the current attachment. |
769 * @param WP_Post $post WP_Post object for the current attachment. |
753 * @param bool $detached Whether the list table contains media not attached |
770 * @param bool $detached Whether the list table contains media not attached |
754 * to any posts. Default true. |
771 * to any posts. Default true. |
755 */ |
772 */ |
756 return apply_filters( 'media_row_actions', $actions, $post, $this->detached ); |
773 return apply_filters( 'media_row_actions', $actions, $post, $this->detached ); |
757 } |
774 } |
758 |
775 |
759 /** |
776 /** |