2008-08-16 09:27:34 +02:00
< ? php
/**
* Edit attachments table for inclusion in administration panels .
*
* @ package WordPress
* @ subpackage Administration
*/
if ( ! defined ( 'ABSPATH' ) ) die ();
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
add_filter ( 'the_title' , 'wp_specialchars' );
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' );
2008-03-18 00:02:12 +01:00
while ( have_posts ()) : the_post ();
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-04-25 17:28:08 +02:00
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' :
?>
2008-09-16 06:24:28 +02:00
< th scope = " row " class = " check-column " >< input type = " checkbox " name = " media[] " value = " <?php the_ID(); ?> " /></ 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-04-28 07:58:45 +02:00
< a href = " media.php?action=edit&attachment_id=<?php the_ID(); ?> " title = " <?php echo attr(sprintf(__('Edit " % s " '), $att_title )); ?> " >
2008-08-20 06:06:36 +02:00
< ? php echo $thumb ; ?>
</ a >
< ? php }
?> </td>
2008-02-19 07:13:20 +01:00
< ? php
// TODO
break ;
case 'media' :
?>
2009-04-28 07:58:45 +02:00
< td < ? php echo $attributes ?> ><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attr(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
2008-02-26 09:54:11 +01:00
< ? php echo strtoupper ( preg_replace ( '/^.*?\.(\w+)$/' , '$1' , get_attached_file ( $post -> ID ))); ?>
2008-08-20 06:06:36 +02:00
< p >
2008-02-19 07:13:20 +01:00
< ? php
2008-09-15 21:28:26 +02:00
$actions = array ();
2008-11-14 20:40:24 +01:00
if ( current_user_can ( 'edit_post' , $post -> ID ) )
$actions [ 'edit' ] = '<a href="' . get_edit_post_link ( $post -> ID , true ) . '">' . __ ( 'Edit' ) . '</a>' ;
if ( current_user_can ( 'delete_post' , $post -> ID ) )
$actions [ 'delete' ] = " <a class='submitdelete' href=' " . wp_nonce_url ( " post.php?action=delete&post= $post->ID " , 'delete-post_' . $post -> ID ) . " ' onclick= \" if ( confirm(' " . js_escape ( sprintf ( ( 'draft' == $post -> post_status ) ? __ ( " You are about to delete this attachment '%s' \n 'Cancel' to stop, 'OK' to delete. " ) : __ ( " You are about to delete this attachment '%s' \n 'Cancel' to stop, 'OK' to delete. " ), $post -> post_title )) . " ') ) { return true;}return false; \" > " . __ ( 'Delete' ) . " </a> " ;
2009-04-28 07:58:45 +02:00
$actions [ 'view' ] = '<a href="' . get_permalink ( $post -> ID ) . '" title="' . attr ( sprintf ( __ ( 'View "%s"' ), $title )) . '" rel="permalink">' . __ ( 'View' ) . '</a>' ;
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>' ;
2008-09-16 06:24:28 +02:00
?> </p></td>
< ? 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 )
$out [] = " <a href='edit.php?tag= $c->slug '> " . wp_specialchars ( sanitize_term_field ( 'name' , $c -> name , $c -> term_id , 'post_tag' , 'display' )) . " </a> " ;
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 ;
2008-11-04 04:22:24 +01:00
$time = get_post_time ( 'G' , true , $post );
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
?>
2008-09-15 19:53:30 +02:00
< td < ? php echo $attributes ?> > </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-04-28 07:58:45 +02:00
< a href = " media.php?action=edit&attachment_id=<?php the_ID(); ?> " title = " <?php echo 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 { ?>
< p >< ? php _e ( 'No posts found.' ) ?> </p>
2008-02-19 07:13:20 +01:00
< ? php
} // end if ( have_posts() )
?>
2008-12-09 19:03:31 +01:00