]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/edit-post-rows.php
Wordpress 2.5.1
[autoinstalls/wordpress.git] / wp-admin / edit-post-rows.php
1 <?php if ( ! defined('ABSPATH') ) die(); ?>
2 <table class="widefat">
3         <thead>
4         <tr>
5
6 <?php $posts_columns = wp_manage_posts_columns(); ?>
7 <?php foreach($posts_columns as $post_column_key => $column_display_name) {
8         if ( 'cb' === $post_column_key )
9                 $class = ' class="check-column"';
10         elseif ( 'comments' === $post_column_key )
11                 $class = ' class="num"';
12         else
13                 $class = '';
14 ?>
15         <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
16 <?php } ?>
17
18         </tr>
19         </thead>
20         <tbody>
21 <?php
22 if ( have_posts() ) {
23 $bgcolor = '';
24 add_filter('the_title','wp_specialchars');
25
26 // Create array of post IDs.
27 $post_ids = array();
28 foreach ( $wp_query->posts as $a_post )
29         $post_ids[] = $a_post->ID;
30
31 $comment_pending_count = get_pending_comments_num($post_ids);
32
33 while (have_posts()) : the_post();
34 $class = 'alternate' == $class ? '' : 'alternate';
35 global $current_user;
36 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
37 $title = get_the_title();
38 if ( empty($title) )
39         $title = __('(no title)');
40 ?>
41         <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
42
43 <?php
44
45 foreach($posts_columns as $column_name=>$column_display_name) {
46
47         switch($column_name) {
48
49         case 'cb':
50                 ?>
51                 <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>
52                 <?php
53                 break;
54         case 'modified':
55         case 'date':
56                 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
57                         $t_time = $h_time = __('Unpublished');
58                 } else {
59                         if ( 'modified' == $column_name ) {
60                                 $t_time = get_the_modified_time(__('Y/m/d g:i:s A'));
61                                 $m_time = $post->post_modified;
62                                 $time = get_post_modified_time('G', true);
63                         } else {
64                                 $t_time = get_the_time(__('Y/m/d g:i:s A'));
65                                 $m_time = $post->post_date;
66                                 $time = get_post_time('G', true);
67                         }
68                         if ( ( abs(time() - $time) ) < 86400 ) {
69                                 if ( ( 'future' == $post->post_status) )
70                                         $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
71                                 else
72                                         $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
73                         } else {
74                                 $h_time = mysql2date(__('Y/m/d'), $m_time);
75                         }
76                 }
77                 ?>
78                 <td><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name) ?></abbr></td>
79                 <?php
80                 break;
81         case 'title':
82                 ?>
83                 <td><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="post.php?action=edit&amp;post=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; } ?></strong>
84                 <?php if ( !empty($post->post_password) ) { _e(' &#8212; <strong>Protected</strong>'); } elseif ('private' == $post->post_status) { _e(' &#8212; <strong>Private</strong>'); } ?></td>
85                 <?php
86                 break;
87
88         case 'categories':
89                 ?>
90                 <td><?php
91                 $categories = get_the_category();
92                 if ( !empty( $categories ) ) {
93                         $out = array();
94                         foreach ( $categories as $c )
95                                 $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
96                         echo join( ', ', $out );
97                 } else {
98                         _e('Uncategorized');
99                 }
100                 ?></td>
101                 <?php
102                 break;
103
104         case 'tags':
105                 ?>
106                 <td><?php
107                 $tags = get_the_tags();
108                 if ( !empty( $tags ) ) {
109                         $out = array();
110                         foreach ( $tags as $c )
111                                 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
112                         echo join( ', ', $out );
113                 } else {
114                         _e('No Tags');
115                 }
116                 ?></td>
117                 <?php
118                 break;
119
120         case 'comments':
121                 ?>
122                 <td class="num"><div class="post-com-count-wrapper">
123                 <?php
124                 $left = isset($comment_pending_count) ? $comment_pending_count[$post->ID] : 0;
125                 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
126                 if ( $left )
127                         echo '<strong>';
128                 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>');
129                 if ( $left )
130                         echo '</strong>';
131                 ?>
132                 </div></td>
133                 <?php
134                 break;
135
136         case 'author':
137                 ?>
138                 <td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
139                 <?php
140                 break;
141
142         case 'status':
143                 ?>
144                 <td>
145                 <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
146                 <?php
147                 switch ( $post->post_status ) {
148                         case 'publish' :
149                         case 'private' :
150                                 _e('Published');
151                                 break;
152                         case 'future' :
153                                 _e('Scheduled');
154                                 break;
155                         case 'pending' :
156                                 _e('Pending Review');
157                                 break;
158                         case 'draft' :
159                                 _e('Unpublished');
160                                 break;
161                 }
162                 ?>
163                 </a>
164                 </td>
165                 <?php
166                 break;
167
168         case 'control_view':
169                 ?>
170                 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
171                 <?php
172                 break;
173
174         case 'control_edit':
175                 ?>
176                 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
177                 <?php
178                 break;
179
180         case 'control_delete':
181                 ?>
182                 <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
183                 <?php
184                 break;
185
186         default:
187                 ?>
188                 <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
189                 <?php
190                 break;
191         }
192 }
193 ?>
194         </tr>
195 <?php
196 endwhile;
197 } else {
198 ?>
199   <tr style='background-color: <?php echo $bgcolor; ?>'>
200     <td colspan="8"><?php _e('No posts found.') ?></td>
201   </tr>
202 <?php
203 } // end if ( have_posts() )
204 ?>
205         </tbody>
206 </table>