2008-08-16 09:27:34 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Edit attachments table for inclusion in administration panels.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
2009-08-03 02:04:45 +02:00
|
|
|
// don't load directly
|
|
|
|
if ( !defined('ABSPATH') )
|
|
|
|
die('-1');
|
2008-11-30 14:17:27 +01:00
|
|
|
|
|
|
|
if ( have_posts() ) { ?>
|
2008-11-17 19:01:00 +01:00
|
|
|
<table class="widefat fixed" cellspacing="0">
|
2008-02-19 07:13:20 +01:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2008-11-19 04:57:18 +01:00
|
|
|
<?php print_column_headers('upload'); ?>
|
2008-02-19 07:13:20 +01:00
|
|
|
</tr>
|
|
|
|
</thead>
|
2008-12-09 19:03:31 +01:00
|
|
|
|
2008-09-29 11:26:21 +02:00
|
|
|
<tfoot>
|
|
|
|
<tr>
|
2008-11-19 04:57:18 +01:00
|
|
|
<?php print_column_headers('upload', false); ?>
|
2008-09-29 11:26:21 +02:00
|
|
|
</tr>
|
|
|
|
</tfoot>
|
2008-12-09 19:03:31 +01:00
|
|
|
|
2008-02-19 07:13:20 +01:00
|
|
|
<tbody id="the-list" class="list:post">
|
|
|
|
<?php
|
2009-05-18 17:11:07 +02:00
|
|
|
add_filter('the_title','esc_html');
|
2008-11-25 20:18:17 +01:00
|
|
|
$alt = '';
|
2008-11-25 20:26:53 +01:00
|
|
|
$posts_columns = get_column_headers('upload');
|
|
|
|
$hidden = get_hidden_columns('upload');
|
2009-07-30 15:39:34 +02: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 20:40:24 +01:00
|
|
|
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
|
2008-02-19 07:13:20 +01:00
|
|
|
global $current_user;
|
|
|
|
$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
|
2008-09-30 23:32:13 +02:00
|
|
|
$att_title = _draft_or_post_title();
|
2008-02-19 07:13:20 +01:00
|
|
|
?>
|
2008-11-14 20:40:24 +01:00
|
|
|
<tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
|
2008-02-19 07:13:20 +01:00
|
|
|
|
|
|
|
<?php
|
2008-09-15 19:53:30 +02: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 07:13:20 +01:00
|
|
|
|
|
|
|
switch($column_name) {
|
|
|
|
|
|
|
|
case 'cb':
|
|
|
|
?>
|
2009-08-19 10:35:24 +02: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 07:13:20 +01:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'icon':
|
2008-09-16 06:24:28 +02:00
|
|
|
$attributes = 'class="column-icon media-icon"' . $style;
|
2008-02-19 07:13:20 +01:00
|
|
|
?>
|
2008-09-16 06:24:28 +02:00
|
|
|
<td <?php echo $attributes ?>><?php
|
2008-08-20 06:06:36 +02:00
|
|
|
if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
|
2009-07-30 15:39:34 +02:00
|
|
|
if ( $is_trash ) echo $thumb;
|
|
|
|
else {
|
2008-08-20 06:06:36 +02:00
|
|
|
?>
|
2010-02-19 21:03:05 +01: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 06:06:36 +02:00
|
|
|
<?php echo $thumb; ?>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<?php }
|
2009-07-30 15:39:34 +02:00
|
|
|
}
|
2008-08-20 06:06:36 +02:00
|
|
|
?></td>
|
2008-02-19 07:13:20 +01:00
|
|
|
<?php
|
|
|
|
// TODO
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'media':
|
|
|
|
?>
|
2010-05-15 22:36:49 +02: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 23:45:11 +01:00
|
|
|
<?php
|
|
|
|
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
|
2010-03-06 09:02:26 +01:00
|
|
|
echo esc_html( strtoupper( $matches[1] ) );
|
2010-03-01 23:45:11 +01:00
|
|
|
else
|
|
|
|
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
|
|
|
|
?>
|
2010-05-15 22:36:49 +02:00
|
|
|
</p>
|
2008-02-19 07:13:20 +01:00
|
|
|
<?php
|
2008-09-15 21:28:26 +02:00
|
|
|
$actions = array();
|
2009-11-10 11:38:19 +01: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 18:59:18 +01: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 07:40:16 +01:00
|
|
|
elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
|
2010-02-05 18:59:18 +01: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-31 03:37:56 +01:00
|
|
|
if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) {
|
|
|
|
$delete_ays = (!$is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : '';
|
2010-02-05 18:59:18 +01: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-31 03:37:56 +01:00
|
|
|
}
|
2009-07-30 15:39:34 +02:00
|
|
|
}
|
2010-01-27 15:44:47 +01:00
|
|
|
if ( !$is_trash ) {
|
|
|
|
$title =_draft_or_post_title($post->post_parent);
|
2009-11-10 11:38:19 +01:00
|
|
|
$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
|
2010-01-27 15:44:47 +01:00
|
|
|
}
|
2009-11-19 18:46:07 +01:00
|
|
|
$actions = apply_filters( 'media_row_actions', $actions, $post );
|
2008-09-15 21:28:26 +02:00
|
|
|
$action_count = count($actions);
|
|
|
|
$i = 0;
|
2008-12-02 20:00:48 +01:00
|
|
|
echo '<div class="row-actions">';
|
2008-09-15 21:28:26 +02:00
|
|
|
foreach ( $actions as $action => $link ) {
|
|
|
|
++$i;
|
|
|
|
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
|
|
|
echo "<span class='$action'>$link$sep</span>";
|
|
|
|
}
|
2008-12-02 20:00:48 +01:00
|
|
|
echo '</div>';
|
2010-05-15 22:36:49 +02:00
|
|
|
?></td>
|
2008-09-16 06:24:28 +02:00
|
|
|
<?php
|
2008-02-19 07:13:20 +01:00
|
|
|
break;
|
|
|
|
|
2008-10-15 07:39:40 +02:00
|
|
|
case 'author':
|
|
|
|
?>
|
|
|
|
<td <?php echo $attributes ?>><?php the_author() ?></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
2008-08-20 06:06:36 +02:00
|
|
|
case 'tags':
|
|
|
|
?>
|
2008-09-15 19:53:30 +02:00
|
|
|
<td <?php echo $attributes ?>><?php
|
2008-08-20 06:06:36 +02:00
|
|
|
$tags = get_the_tags();
|
|
|
|
if ( !empty( $tags ) ) {
|
|
|
|
$out = array();
|
|
|
|
foreach ( $tags as $c )
|
2009-05-18 17:11:07 +02: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 06:06:36 +02:00
|
|
|
echo join( ', ', $out );
|
|
|
|
} else {
|
|
|
|
_e('No Tags');
|
|
|
|
}
|
|
|
|
?></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
2008-02-19 07:13:20 +01:00
|
|
|
case 'desc':
|
|
|
|
?>
|
2008-09-15 19:53:30 +02:00
|
|
|
<td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
|
2008-02-19 07:13:20 +01: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-14 04:00:32 +02:00
|
|
|
$time = get_post_time( 'G', true, $post, false );
|
2008-02-22 23:38:52 +01:00
|
|
|
if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
|
|
|
|
if ( $t_diff < 0 )
|
2008-02-19 07:13:20 +01: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 19:53:30 +02:00
|
|
|
<td <?php echo $attributes ?>><?php echo $h_time ?></td>
|
2008-02-19 07:13:20 +01:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'parent':
|
2008-03-27 03:50:01 +01:00
|
|
|
if ( $post->post_parent > 0 ) {
|
|
|
|
if ( get_post($post->post_parent) ) {
|
2008-09-30 23:32:13 +02:00
|
|
|
$title =_draft_or_post_title($post->post_parent);
|
2008-03-27 03:50:01 +01:00
|
|
|
}
|
|
|
|
?>
|
2008-09-15 19:53:30 +02: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-27 03:50:01 +01:00
|
|
|
<?php
|
2008-02-22 23:38:52 +01:00
|
|
|
} else {
|
2008-03-27 03:50:01 +01:00
|
|
|
?>
|
2009-11-17 04:08:38 +01: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-27 03:50:01 +01:00
|
|
|
<?php
|
2008-02-22 23:38:52 +01:00
|
|
|
}
|
2008-03-27 03:50:01 +01:00
|
|
|
|
2008-02-19 07:13:20 +01:00
|
|
|
break;
|
|
|
|
|
2008-03-11 22:09:07 +01:00
|
|
|
case 'comments':
|
2008-09-15 19:53:30 +02:00
|
|
|
$attributes = 'class="comments column-comments num"' . $style;
|
2008-03-11 22:09:07 +01:00
|
|
|
?>
|
2008-09-15 19:53:30 +02:00
|
|
|
<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
|
2008-03-11 22:09:07 +01:00
|
|
|
<?php
|
|
|
|
$left = get_pending_comments_num( $post->ID );
|
|
|
|
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
|
|
|
if ( $left )
|
|
|
|
echo '<strong>';
|
2009-03-13 04:53:39 +01: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 22:09:07 +01:00
|
|
|
if ( $left )
|
|
|
|
echo '</strong>';
|
|
|
|
?>
|
2008-03-20 22:40:17 +01:00
|
|
|
</div></td>
|
2008-03-11 22:09:07 +01:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
2008-08-20 06:06:36 +02:00
|
|
|
case 'actions':
|
2008-02-19 07:13:20 +01:00
|
|
|
?>
|
2008-09-15 19:53:30 +02:00
|
|
|
<td <?php echo $attributes ?>>
|
2009-05-05 21:43:53 +02: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 06:06:36 +02:00
|
|
|
<a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a>
|
|
|
|
</td>
|
2008-02-19 07:13:20 +01:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
?>
|
2008-09-15 19:53:30 +02:00
|
|
|
<td <?php echo $attributes ?>><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
|
2008-02-19 07:13:20 +01:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</tr>
|
2008-11-30 14:17:27 +01:00
|
|
|
<?php endwhile; ?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<?php } else { ?>
|
|
|
|
|
2009-05-05 04:31:32 +02:00
|
|
|
<p><?php _e('No media attachments found.') ?></p>
|
2008-11-30 14:17:27 +01:00
|
|
|
|
2008-02-19 07:13:20 +01:00
|
|
|
<?php
|
|
|
|
} // end if ( have_posts() )
|
|
|
|
?>
|
2008-12-09 19:03:31 +01:00
|
|
|
|