2008-08-16 03:27:34 -04:00
< ? php
/**
* Edit attachments table for inclusion in administration panels .
*
* @ package WordPress
* @ subpackage Administration
*/
if ( ! defined ( 'ABSPATH' ) ) die ();
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-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-02-19 01:13:20 -05:00
< tbody id = " the-list " class = " list:post " >
< ? php
add_filter ( 'the_title' , 'wp_specialchars' );
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' );
2008-03-17 19:02:12 -04:00
while ( have_posts ()) : the_post ();
2008-11-14 14:40:24 -05:00
$alt = ( 'alternate' == $alt ) ? '' : 'alternate' ;
2008-02-19 01:13:20 -05:00
global $current_user ;
$post_owner = ( $current_user -> ID == $post -> post_author ? 'self' : 'other' );
2008-09-30 17:32:13 -04:00
$att_title = _draft_or_post_title ();
2008-04-25 11:28:08 -04:00
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' :
?>
2008-09-16 00:24:28 -04:00
< th scope = " row " class = " check-column " >< input type = " checkbox " name = " media[] " value = " <?php the_ID(); ?> " /></ 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 ) ) {
?>
< a href = " media.php?action=edit&attachment_id=<?php the_ID(); ?> " title = " <?php echo attribute_escape(sprintf(__('Edit " % s " '), $att_title )); ?> " >
< ? php echo $thumb ; ?>
</ a >
< ? php }
?> </td>
2008-02-19 01:13:20 -05:00
< ? php
// TODO
break ;
case 'media' :
?>
2008-09-15 13:53:30 -04:00
< td < ? php echo $attributes ?> ><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
2008-02-26 03:54:11 -05:00
< ? php echo strtoupper ( preg_replace ( '/^.*?\.(\w+)$/' , '$1' , get_attached_file ( $post -> ID ))); ?>
2008-08-20 00:06:36 -04:00
< p >
2008-02-19 01:13:20 -05:00
< ? php
2008-09-15 15:28:26 -04:00
$actions = array ();
2008-11-14 14:40:24 -05: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> " ;
2008-09-15 15:28:26 -04:00
$actions [ 'view' ] = '<a href="' . get_permalink ( $post -> ID ) . '" title="' . attribute_escape ( sprintf ( __ ( 'View "%s"' ), $title )) . '" rel="permalink">' . __ ( 'View' ) . '</a>' ;
$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>' ;
2008-09-16 00:24:28 -04:00
?> </p></td>
< ? 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 )
$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 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 ;
2008-11-03 22:22:24 -05:00
$time = get_post_time ( 'G' , true , $post );
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
?>
2008-09-15 13:53:30 -04:00
< td < ? php echo $attributes ?> > </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>' ;
2008-11-19 23:51:47 -05:00
comments_number ( " <a href='edit-comments.php?p= $id ' title=' $pending_phrase ' class='post-com-count'><span class='comment-count'> " . __ ( '0' ) . '</span></a>' , " <a href='edit-comments.php?p= $id ' title=' $pending_phrase ' class='post-com-count'><span class='comment-count'> " . __ ( '1' ) . '</span></a>' , " <a href='edit-comments.php?p= $id ' title=' $pending_phrase ' class='post-com-count'><span class='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 ?> >
2008-08-20 00:06:36 -04:00
< a href = " media.php?action=edit&attachment_id=<?php the_ID(); ?> " title = " <?php echo attribute_escape(sprintf(__('Edit " % s " '), $att_title )); ?> " >< ? php _e ( 'Edit' ); ?> </a> |
< 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 { ?>
< p >< ? php _e ( 'No posts found.' ) ?> </p>
2008-02-19 01:13:20 -05:00
< ? php
} // end if ( have_posts() )
?>
2008-11-30 08:17:27 -05:00