2008-08-16 03:27:34 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Edit attachments table for inclusion in administration panels.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
2009-08-02 20:04:45 -04:00
|
|
|
// don't load directly
|
|
|
|
if ( !defined('ABSPATH') )
|
|
|
|
die('-1');
|
2008-11-30 08:17:27 -05:00
|
|
|
|
|
|
|
if ( have_posts() ) { ?>
|
2008-11-17 13:01:00 -05:00
|
|
|
<table class="widefat fixed" cellspacing="0">
|
2008-02-19 01:13:20 -05:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2008-11-18 22:57:18 -05:00
|
|
|
<?php print_column_headers('upload'); ?>
|
2008-02-19 01:13:20 -05:00
|
|
|
</tr>
|
|
|
|
</thead>
|
2008-12-09 13:03:31 -05:00
|
|
|
|
2008-09-29 05:26:21 -04:00
|
|
|
<tfoot>
|
|
|
|
<tr>
|
2008-11-18 22:57:18 -05:00
|
|
|
<?php print_column_headers('upload', false); ?>
|
2008-09-29 05:26:21 -04:00
|
|
|
</tr>
|
|
|
|
</tfoot>
|
2008-12-09 13:03:31 -05:00
|
|
|
|
2008-02-19 01:13:20 -05:00
|
|
|
<tbody id="the-list" class="list:post">
|
|
|
|
<?php
|
2009-05-18 11:11:07 -04:00
|
|
|
add_filter('the_title','esc_html');
|
2008-11-25 14:18:17 -05:00
|
|
|
$alt = '';
|
2008-11-25 14:26:53 -05:00
|
|
|
$posts_columns = get_column_headers('upload');
|
|
|
|
$hidden = get_hidden_columns('upload');
|
2009-07-30 09:39:34 -04:00
|
|
|
|
|
|
|
while ( have_posts() ) : the_post();
|
|
|
|
|
|
|
|
if ( $is_trash && $post->post_status != 'trash' )
|
|
|
|
continue;
|
|
|
|
elseif ( !$is_trash && $post->post_status == 'trash' )
|
|
|
|
continue;
|
|
|
|
|
2008-11-14 14:40:24 -05:00
|
|
|
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
|
2010-06-24 11:01:29 -04:00
|
|
|
|
|
|
|
$post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
|
2008-09-30 17:32:13 -04:00
|
|
|
$att_title = _draft_or_post_title();
|
2008-02-19 01:13:20 -05:00
|
|
|
?>
|
2008-11-14 14:40:24 -05:00
|
|
|
<tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
|
2008-02-19 01:13:20 -05:00
|
|
|
|
|
|
|
<?php
|
2008-09-15 13:53:30 -04:00
|
|
|
foreach ($posts_columns as $column_name => $column_display_name ) {
|
|
|
|
$class = "class=\"$column_name column-$column_name\"";
|
|
|
|
|
|
|
|
$style = '';
|
|
|
|
if ( in_array($column_name, $hidden) )
|
|
|
|
$style = ' style="display:none;"';
|
|
|
|
|
|
|
|
$attributes = "$class$style";
|
2008-02-19 01:13:20 -05:00
|
|
|
|
|
|
|
switch($column_name) {
|
|
|
|
|
|
|
|
case 'cb':
|
|
|
|
?>
|
2009-08-19 04:35:24 -04:00
|
|
|
<th scope="row" class="check-column"><?php if ( current_user_can('edit_post', $post->ID) ) { ?><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /><?php } ?></th>
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'icon':
|
2008-09-16 00:24:28 -04:00
|
|
|
$attributes = 'class="column-icon media-icon"' . $style;
|
2008-02-19 01:13:20 -05:00
|
|
|
?>
|
2008-09-16 00:24:28 -04:00
|
|
|
<td <?php echo $attributes ?>><?php
|
2008-08-20 00:06:36 -04:00
|
|
|
if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
|
2009-07-30 09:39:34 -04:00
|
|
|
if ( $is_trash ) echo $thumb;
|
|
|
|
else {
|
2008-08-20 00:06:36 -04:00
|
|
|
?>
|
2010-02-19 15:03:05 -05:00
|
|
|
<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>">
|
2008-08-20 00:06:36 -04:00
|
|
|
<?php echo $thumb; ?>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<?php }
|
2009-07-30 09:39:34 -04:00
|
|
|
}
|
2008-08-20 00:06:36 -04:00
|
|
|
?></td>
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
|
|
|
// TODO
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'media':
|
|
|
|
?>
|
2010-05-15 16:36:49 -04:00
|
|
|
<td <?php echo $attributes ?>><strong><?php if ( $is_trash ) echo $att_title; else { ?><a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"><?php echo $att_title; ?></a><?php } ?></strong>
|
|
|
|
<p>
|
2010-03-01 17:45:11 -05:00
|
|
|
<?php
|
|
|
|
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
|
2010-03-06 03:02:26 -05:00
|
|
|
echo esc_html( strtoupper( $matches[1] ) );
|
2010-03-01 17:45:11 -05:00
|
|
|
else
|
|
|
|
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
|
|
|
|
?>
|
2010-05-15 16:36:49 -04:00
|
|
|
</p>
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
2008-09-15 15:28:26 -04:00
|
|
|
$actions = array();
|
2009-11-10 05:38:19 -05:00
|
|
|
if ( current_user_can('edit_post', $post->ID) && !$is_trash )
|
|
|
|
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
|
|
|
|
if ( current_user_can('delete_post', $post->ID) ) {
|
|
|
|
if ( $is_trash )
|
2010-02-05 12:59:18 -05:00
|
|
|
$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-attachment_' . $post->ID) . "'>" . __('Restore') . "</a>";
|
2009-12-12 01:40:16 -05:00
|
|
|
elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
|
2010-02-05 12:59:18 -05:00
|
|
|
$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-attachment_' . $post->ID) . "'>" . __('Trash') . "</a>";
|
2009-12-30 21:37:56 -05:00
|
|
|
if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) {
|
|
|
|
$delete_ays = (!$is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : '';
|
2010-02-05 12:59:18 -05:00
|
|
|
$actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-attachment_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
|
2009-12-30 21:37:56 -05:00
|
|
|
}
|
2009-07-30 09:39:34 -04:00
|
|
|
}
|
2010-01-27 09:44:47 -05:00
|
|
|
if ( !$is_trash ) {
|
|
|
|
$title =_draft_or_post_title($post->post_parent);
|
2009-11-10 05:38:19 -05:00
|
|
|
$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
|
2010-01-27 09:44:47 -05:00
|
|
|
}
|
2009-11-19 12:46:07 -05:00
|
|
|
$actions = apply_filters( 'media_row_actions', $actions, $post );
|
2008-09-15 15:28:26 -04:00
|
|
|
$action_count = count($actions);
|
|
|
|
$i = 0;
|
2008-12-02 14:00:48 -05:00
|
|
|
echo '<div class="row-actions">';
|
2008-09-15 15:28:26 -04:00
|
|
|
foreach ( $actions as $action => $link ) {
|
|
|
|
++$i;
|
|
|
|
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
|
|
|
echo "<span class='$action'>$link$sep</span>";
|
|
|
|
}
|
2008-12-02 14:00:48 -05:00
|
|
|
echo '</div>';
|
2010-05-15 16:36:49 -04:00
|
|
|
?></td>
|
2008-09-16 00:24:28 -04:00
|
|
|
<?php
|
2008-02-19 01:13:20 -05:00
|
|
|
break;
|
|
|
|
|
2008-10-15 01:39:40 -04:00
|
|
|
case 'author':
|
|
|
|
?>
|
|
|
|
<td <?php echo $attributes ?>><?php the_author() ?></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
2008-08-20 00:06:36 -04:00
|
|
|
case 'tags':
|
|
|
|
?>
|
2008-09-15 13:53:30 -04:00
|
|
|
<td <?php echo $attributes ?>><?php
|
2008-08-20 00:06:36 -04:00
|
|
|
$tags = get_the_tags();
|
|
|
|
if ( !empty( $tags ) ) {
|
|
|
|
$out = array();
|
|
|
|
foreach ( $tags as $c )
|
2009-05-18 11:11:07 -04:00
|
|
|
$out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
|
2008-08-20 00:06:36 -04:00
|
|
|
echo join( ', ', $out );
|
|
|
|
} else {
|
|
|
|
_e('No Tags');
|
|
|
|
}
|
|
|
|
?></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
2008-02-19 01:13:20 -05:00
|
|
|
case 'desc':
|
|
|
|
?>
|
2008-09-15 13:53:30 -04:00
|
|
|
<td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'date':
|
|
|
|
if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
|
|
|
|
$t_time = $h_time = __('Unpublished');
|
|
|
|
} else {
|
|
|
|
$t_time = get_the_time(__('Y/m/d g:i:s A'));
|
|
|
|
$m_time = $post->post_date;
|
2009-05-13 22:00:32 -04:00
|
|
|
$time = get_post_time( 'G', true, $post, false );
|
2008-02-22 17:38:52 -05:00
|
|
|
if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
|
|
|
|
if ( $t_diff < 0 )
|
2008-02-19 01:13:20 -05:00
|
|
|
$h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
|
|
|
|
else
|
|
|
|
$h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
|
|
|
|
} else {
|
|
|
|
$h_time = mysql2date(__('Y/m/d'), $m_time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2008-09-15 13:53:30 -04:00
|
|
|
<td <?php echo $attributes ?>><?php echo $h_time ?></td>
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'parent':
|
2008-03-26 22:50:01 -04:00
|
|
|
if ( $post->post_parent > 0 ) {
|
|
|
|
if ( get_post($post->post_parent) ) {
|
2008-09-30 17:32:13 -04:00
|
|
|
$title =_draft_or_post_title($post->post_parent);
|
2008-03-26 22:50:01 -04:00
|
|
|
}
|
|
|
|
?>
|
2008-09-15 13:53:30 -04:00
|
|
|
<td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?></td>
|
2008-03-26 22:50:01 -04:00
|
|
|
<?php
|
2008-02-22 17:38:52 -05:00
|
|
|
} else {
|
2008-03-26 22:50:01 -04:00
|
|
|
?>
|
2009-11-16 22:08:38 -05:00
|
|
|
<td <?php echo $attributes ?>><?php _e('(Unattached)'); ?><br />
|
|
|
|
<a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php echo $post->ID ?>');return false;" href="#the-list"><?php _e('Attach'); ?></a></td>
|
2008-03-26 22:50:01 -04:00
|
|
|
<?php
|
2008-02-22 17:38:52 -05:00
|
|
|
}
|
2008-03-26 22:50:01 -04:00
|
|
|
|
2008-02-19 01:13:20 -05:00
|
|
|
break;
|
|
|
|
|
2008-03-11 17:09:07 -04:00
|
|
|
case 'comments':
|
2008-09-15 13:53:30 -04:00
|
|
|
$attributes = 'class="comments column-comments num"' . $style;
|
2008-03-11 17:09:07 -04:00
|
|
|
?>
|
2008-09-15 13:53:30 -04:00
|
|
|
<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
|
2008-03-11 17:09:07 -04:00
|
|
|
<?php
|
|
|
|
$left = get_pending_comments_num( $post->ID );
|
|
|
|
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
|
|
|
if ( $left )
|
|
|
|
echo '<strong>';
|
2009-03-12 23:53:39 -04:00
|
|
|
comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
|
2008-03-11 17:09:07 -04:00
|
|
|
if ( $left )
|
|
|
|
echo '</strong>';
|
|
|
|
?>
|
2008-03-20 17:40:17 -04:00
|
|
|
</div></td>
|
2008-03-11 17:09:07 -04:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
2008-08-20 00:06:36 -04:00
|
|
|
case 'actions':
|
2008-02-19 01:13:20 -05:00
|
|
|
?>
|
2008-09-15 13:53:30 -04:00
|
|
|
<td <?php echo $attributes ?>>
|
2009-05-05 15:43:53 -04:00
|
|
|
<a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"><?php _e('Edit'); ?></a> |
|
2008-08-20 00:06:36 -04:00
|
|
|
<a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a>
|
|
|
|
</td>
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
?>
|
2008-09-15 13:53:30 -04:00
|
|
|
<td <?php echo $attributes ?>><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</tr>
|
2008-11-30 08:17:27 -05:00
|
|
|
<?php endwhile; ?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<?php } else { ?>
|
|
|
|
|
2009-05-04 22:31:32 -04:00
|
|
|
<p><?php _e('No media attachments found.') ?></p>
|
2008-11-30 08:17:27 -05:00
|
|
|
|
2008-02-19 01:13:20 -05:00
|
|
|
<?php
|
|
|
|
} // end if ( have_posts() )
|
|
|
|
?>
|
2008-12-09 13:03:31 -05:00
|
|
|
|