2008-08-16 09:27:34 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Edit posts rows table for inclusion in administration panels.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! defined('ABSPATH') ) die();
|
|
|
|
?>
|
2007-08-24 00:19:53 +02:00
|
|
|
<table class="widefat">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
|
2008-02-12 06:51:53 +01:00
|
|
|
<?php $posts_columns = wp_manage_posts_columns(); ?>
|
2008-03-15 07:14:03 +01:00
|
|
|
<?php foreach($posts_columns as $post_column_key => $column_display_name) {
|
|
|
|
if ( 'cb' === $post_column_key )
|
|
|
|
$class = ' class="check-column"';
|
|
|
|
elseif ( 'comments' === $post_column_key )
|
|
|
|
$class = ' class="num"';
|
|
|
|
else
|
|
|
|
$class = '';
|
|
|
|
?>
|
|
|
|
<th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2008-02-27 01:46:27 +01:00
|
|
|
<tbody>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
if ( have_posts() ) {
|
|
|
|
$bgcolor = '';
|
|
|
|
add_filter('the_title','wp_specialchars');
|
2008-04-22 23:26:01 +02:00
|
|
|
|
|
|
|
// Create array of post IDs.
|
|
|
|
$post_ids = array();
|
|
|
|
foreach ( $wp_query->posts as $a_post )
|
|
|
|
$post_ids[] = $a_post->ID;
|
|
|
|
|
|
|
|
$comment_pending_count = get_pending_comments_num($post_ids);
|
|
|
|
|
2008-03-18 00:02:12 +01:00
|
|
|
while (have_posts()) : the_post();
|
|
|
|
$class = 'alternate' == $class ? '' : 'alternate';
|
2007-08-24 00:19:53 +02:00
|
|
|
global $current_user;
|
|
|
|
$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
|
2008-07-29 07:22:58 +02:00
|
|
|
$edit_link = get_edit_post_link( $post->ID );
|
2008-03-18 03:22:07 +01:00
|
|
|
$title = get_the_title();
|
|
|
|
if ( empty($title) )
|
|
|
|
$title = __('(no title)');
|
2007-08-24 00:19:53 +02:00
|
|
|
?>
|
2008-02-10 09:10:11 +01:00
|
|
|
<tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
|
2007-08-24 00:19:53 +02:00
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
foreach($posts_columns as $column_name=>$column_display_name) {
|
|
|
|
|
|
|
|
switch($column_name) {
|
|
|
|
|
2008-02-10 09:10:11 +01:00
|
|
|
case 'cb':
|
2007-08-24 00:19:53 +02:00
|
|
|
?>
|
2008-03-20 05:30:38 +01:00
|
|
|
<th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /><?php } ?></th>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
case 'modified':
|
|
|
|
case 'date':
|
2008-02-15 07:44:17 +01:00
|
|
|
if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
|
|
|
|
$t_time = $h_time = __('Unpublished');
|
2008-02-10 09:10:11 +01:00
|
|
|
} else {
|
2008-02-15 07:44:17 +01:00
|
|
|
if ( 'modified' == $column_name ) {
|
|
|
|
$t_time = get_the_modified_time(__('Y/m/d g:i:s A'));
|
|
|
|
$m_time = $post->post_modified;
|
2008-02-23 23:11:47 +01:00
|
|
|
$time = get_post_modified_time('G', true);
|
2008-02-15 07:44:17 +01:00
|
|
|
} else {
|
|
|
|
$t_time = get_the_time(__('Y/m/d g:i:s A'));
|
|
|
|
$m_time = $post->post_date;
|
2008-02-23 23:11:47 +01:00
|
|
|
$time = get_post_time('G', true);
|
2008-02-15 07:44:17 +01:00
|
|
|
}
|
|
|
|
if ( ( abs(time() - $time) ) < 86400 ) {
|
2008-02-11 22:52:50 +01:00
|
|
|
if ( ( 'future' == $post->post_status) )
|
2008-02-15 07:44:17 +01:00
|
|
|
$h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
|
2008-02-11 22:52:50 +01:00
|
|
|
else
|
2008-02-15 07:44:17 +01:00
|
|
|
$h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
|
2008-02-11 22:52:50 +01:00
|
|
|
} else {
|
2008-02-15 07:44:17 +01:00
|
|
|
$h_time = mysql2date(__('Y/m/d'), $m_time);
|
2008-02-11 22:52:50 +01:00
|
|
|
}
|
2008-02-10 09:10:11 +01:00
|
|
|
}
|
2008-02-15 07:44:17 +01:00
|
|
|
?>
|
2008-04-10 20:59:17 +02:00
|
|
|
<td><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name) ?></abbr></td>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
case 'title':
|
|
|
|
?>
|
2008-07-29 07:22:58 +02:00
|
|
|
<td><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; } ?></strong>
|
2008-03-19 22:33:47 +01:00
|
|
|
<?php if ( !empty($post->post_password) ) { _e(' — <strong>Protected</strong>'); } elseif ('private' == $post->post_status) { _e(' — <strong>Private</strong>'); } ?></td>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'categories':
|
|
|
|
?>
|
2008-02-10 09:10:11 +01:00
|
|
|
<td><?php
|
|
|
|
$categories = get_the_category();
|
|
|
|
if ( !empty( $categories ) ) {
|
|
|
|
$out = array();
|
|
|
|
foreach ( $categories as $c )
|
2008-02-14 22:57:19 +01:00
|
|
|
$out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
|
2008-02-10 09:10:11 +01:00
|
|
|
echo join( ', ', $out );
|
|
|
|
} else {
|
|
|
|
_e('Uncategorized');
|
|
|
|
}
|
|
|
|
?></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'tags':
|
|
|
|
?>
|
|
|
|
<td><?php
|
|
|
|
$tags = get_the_tags();
|
|
|
|
if ( !empty( $tags ) ) {
|
|
|
|
$out = array();
|
|
|
|
foreach ( $tags as $c )
|
2008-02-14 22:57:19 +01:00
|
|
|
$out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
|
2008-02-10 09:10:11 +01:00
|
|
|
echo join( ', ', $out );
|
|
|
|
} else {
|
|
|
|
_e('No Tags');
|
|
|
|
}
|
|
|
|
?></td>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'comments':
|
|
|
|
?>
|
2008-03-20 22:40:17 +01:00
|
|
|
<td class="num"><div class="post-com-count-wrapper">
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
2008-04-22 23:26:01 +02:00
|
|
|
$left = isset($comment_pending_count) ? $comment_pending_count[$post->ID] : 0;
|
2007-08-24 00:19:53 +02:00
|
|
|
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
|
|
|
if ( $left )
|
|
|
|
echo '<strong>';
|
2008-03-06 11:09:14 +01:00
|
|
|
comments_number("<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
|
2007-08-24 00:19:53 +02:00
|
|
|
if ( $left )
|
|
|
|
echo '</strong>';
|
|
|
|
?>
|
2008-03-20 22:40:17 +01:00
|
|
|
</div></td>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'author':
|
|
|
|
?>
|
2008-02-10 09:10:11 +01:00
|
|
|
<td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'status':
|
|
|
|
?>
|
|
|
|
<td>
|
2008-03-18 03:22:07 +01:00
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
|
2008-02-10 09:10:11 +01:00
|
|
|
<?php
|
|
|
|
switch ( $post->post_status ) {
|
|
|
|
case 'publish' :
|
|
|
|
case 'private' :
|
|
|
|
_e('Published');
|
|
|
|
break;
|
|
|
|
case 'future' :
|
|
|
|
_e('Scheduled');
|
|
|
|
break;
|
|
|
|
case 'pending' :
|
|
|
|
_e('Pending Review');
|
|
|
|
break;
|
|
|
|
case 'draft' :
|
|
|
|
_e('Unpublished');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
?>
|
2008-03-06 10:58:47 +01:00
|
|
|
</a>
|
2008-02-10 09:10:11 +01:00
|
|
|
</td>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'control_view':
|
|
|
|
?>
|
|
|
|
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'control_edit':
|
|
|
|
?>
|
2008-07-29 07:22:58 +02:00
|
|
|
<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'control_delete':
|
|
|
|
?>
|
2008-02-27 01:46:27 +01:00
|
|
|
<td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
?>
|
|
|
|
<td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2007-09-04 01:32:58 +02:00
|
|
|
</tr>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
endwhile;
|
|
|
|
} else {
|
|
|
|
?>
|
2007-09-04 01:32:58 +02:00
|
|
|
<tr style='background-color: <?php echo $bgcolor; ?>'>
|
|
|
|
<td colspan="8"><?php _e('No posts found.') ?></td>
|
|
|
|
</tr>
|
2007-08-24 00:19:53 +02:00
|
|
|
<?php
|
|
|
|
} // end if ( have_posts() )
|
|
|
|
?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|