271
public function display_rows() {
274
add_filter( 'the_title','esc_html' );
276
while ( have_posts() ) : the_post();
277
$user_can_edit = current_user_can( 'edit_post', $post->ID );
279
if ( $this->is_trash && $post->post_status != 'trash'
280
|| !$this->is_trash && $post->post_status == 'trash' )
283
$post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other';
284
$att_title = _draft_or_post_title();
286
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
289
list( $columns, $hidden ) = $this->get_column_info();
290
foreach ( $columns as $column_name => $column_display_name ) {
291
$class = "class='$column_name column-$column_name'";
294
if ( in_array( $column_name, $hidden ) )
295
$style = ' style="display:none;"';
297
$attributes = $class . $style;
299
switch ( $column_name ) {
303
<th scope="row" class="check-column">
304
<?php if ( $user_can_edit ) { ?>
305
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php echo sprintf( __( 'Select %s' ), $att_title );?></label>
306
<input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?>" value="<?php the_ID(); ?>" />
314
* Handles the checkbox column output.
319
* @param WP_Post $post The current WP_Post object.
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() );
326
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
331
* Handles the title column output.
336
* @param WP_Post $post The current WP_Post object.
338
public function column_title( $post ) {
313
339
list( $mime ) = explode( '/', $post->post_mime_type );
314
$attributes = 'class="column-icon media-icon ' . $mime . '-icon"' . $style;
316
<td <?php echo $attributes ?>><?php
317
if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
318
if ( $this->is_trash || ! $user_can_edit ) {
322
<a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
323
<?php echo $thumb; ?>
335
<td <?php echo $attributes ?>><strong>
336
<?php if ( $this->is_trash || ! $user_can_edit ) {
339
<a href="<?php echo get_edit_post_link( $post->ID ); ?>"
340
title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
341
<?php echo $att_title; ?></a>
343
_media_states( $post ); ?></strong>
344
<p class="filename"><?php echo wp_basename( $post->guid ); ?></p>
346
echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
354
<td <?php echo $attributes ?>><?php
355
printf( '<a href="%s">%s</a>',
356
esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
365
<td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
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 = '';
345
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
346
$link_start = '<a href="' . get_edit_post_link( $post->ID ) . '">';
350
$class = $thumb ? ' class="has-media-icon"' : '';
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>
359
<span aria-hidden="true"><?php echo $title; ?></span>
360
<span class="screen-reader-text"><?php printf( __( 'Edit “%s”' ), $title ); ?></span>
361
<?php echo $link_end; ?>
362
<?php _media_states( $post ); ?>
364
<p class="filename"><span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span><?php echo wp_basename( $post->guid ); ?></p>
369
* Handles the author column output.
374
* @param WP_Post $post The current WP_Post object.
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' ) ),
384
* Handles the description column output.
389
* @param WP_Post $post The current WP_Post object.
391
public function column_desc( $post ) {
392
echo has_excerpt() ? $post->post_excerpt : '';
396
* Handles the date column output.
401
* @param WP_Post $post The current WP_Post object.
403
public function column_date( $post ) {
370
404
if ( '0000-00-00 00:00:00' == $post->post_date ) {
371
405
$h_time = __( 'Unpublished' );
373
407
$m_time = $post->post_date;
374
408
$time = get_post_time( 'G', true, $post, false );
375
409
if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
377
411
$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
379
413
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
381
416
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
385
<td <?php echo $attributes ?>><?php echo $h_time ?></td>
390
if ( $post->post_parent > 0 )
424
* Handles the parent column output.
429
* @param WP_Post $post The current WP_Post object.
431
public function column_parent( $post ) {
432
$user_can_edit = current_user_can( 'edit_post', $post->ID );
434
if ( $post->post_parent > 0 ) {
391
435
$parent = get_post( $post->post_parent );
396
441
$title = _draft_or_post_title( $post->post_parent );
397
442
$parent_type = get_post_type_object( $parent->post_type );
399
<td <?php echo $attributes ?>><strong>
400
<?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
401
<a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
402
<?php echo $title ?></a><?php
406
<?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
408
if ( $user_can_edit ):
409
$detach_url = add_query_arg( array(
410
'parent_post_id' => $post->post_parent,
411
'media[]' => $post->ID,
412
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
413
), 'upload.php' ); ?>
414
<a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
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
451
<?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
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>
420
<td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
462
_e( '(Unattached)' ); ?><br />
421
463
<?php if ( $user_can_edit ) { ?>
422
464
<a class="hide-if-no-js"
423
465
onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
424
466
href="#the-list">
425
467
<?php _e( 'Attach' ); ?></a>
432
$attributes = 'class="comments column-comments num"' . $style;
434
<td <?php echo $attributes ?>>
435
<div class="post-com-count-wrapper">
473
* Handles the comments column output.
478
* @param WP_Post $post The current WP_Post object.
480
public function column_comments( $post ) {
481
echo '<div class="post-com-count-wrapper">';
437
483
$pending_comments = get_pending_comments_num( $post->ID );
439
484
$this->comments_bubble( $post->ID, $pending_comments );
447
if ( 'categories' == $column_name )
490
* Handles output for the default column.
495
* @param WP_Post $post The current WP_Post object.
496
* @param string $column_name Current column name.
498
public function column_default( $post, $column_name ) {
499
if ( 'categories' == $column_name ) {
448
500
$taxonomy = 'category';
449
elseif ( 'tags' == $column_name )
501
} elseif ( 'tags' == $column_name ) {
450
502
$taxonomy = 'post_tag';
451
elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
503
} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
452
504
$taxonomy = substr( $column_name, 9 );
454
506
$taxonomy = false;
456
509
if ( $taxonomy ) {
457
echo '<td ' . $attributes . '>';
458
if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
510
$terms = get_the_terms( $post->ID, $taxonomy );
511
if ( is_array( $terms ) ) {
460
513
foreach ( $terms as $t ) {
461
514
$posts_in_term_qv = array();
470
523
/* translators: used between list items, there is a space after the comma */
471
524
echo join( __( ', ' ), $out );
526
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>';
479
<td <?php echo $attributes ?>><?php
481
* Fires for each custom column in the Media list table.
483
* Custom columns are registered using the 'manage_media_columns' filter.
487
* @param string $column_name Name of the custom column.
488
* @param int $post_id Attachment ID.
490
do_action( 'manage_media_custom_column', $column_name, $post->ID );
533
* Fires for each custom column in the Media list table.
535
* Custom columns are registered using the {@see 'manage_media_columns'} filter.
539
* @param string $column_name Name of the custom column.
540
* @param int $post_id Attachment ID.
542
do_action( 'manage_media_custom_column', $column_name, $post->ID );
547
* @global WP_Post $post
549
public function display_rows() {
552
add_filter( 'the_title','esc_html' );
554
while ( have_posts() ) : the_post();
556
( $this->is_trash && $post->post_status != 'trash' )
557
|| ( ! $this->is_trash && $post->post_status == 'trash' )
561
$post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other';
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 ); ?>
571
* Gets the name of the default primary column.
576
* @return string Name of the default primary column, in this case, 'title'.
578
protected function get_default_primary_column_name() {
502
583
* @param WP_Post $post
503
584
* @param string $att_title
505
588
private function _get_row_actions( $post, $att_title ) {
506
589
$actions = array();