Changeset 8729
- Timestamp:
- 08/25/2008 08:21:27 PM (16 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-post-rows.php
r8682 r8729 30 30 <?php 31 31 if ( have_posts() ) { 32 $bgcolor = ''; 33 add_filter('the_title','wp_specialchars'); 34 35 // Create array of post IDs. 36 $post_ids = array(); 37 foreach ( $wp_query->posts as $a_post ) 38 $post_ids[] = $a_post->ID; 39 40 $comment_pending_count = get_pending_comments_num($post_ids); 41 42 while (have_posts()) : the_post(); 43 $class = 'alternate' == $class ? '' : 'alternate'; 44 global $current_user; 45 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); 46 $edit_link = get_edit_post_link( $post->ID ); 47 $title = get_the_title(); 48 if ( empty($title) ) 49 $title = __('(no title)'); 50 ?> 51 <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top"> 52 53 <?php 54 55 foreach($posts_columns as $column_name=>$column_display_name) { 56 57 switch($column_name) { 58 59 case 'cb': 60 ?> 61 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> 62 <?php 63 break; 64 case 'modified': 65 case 'date': 66 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { 67 $t_time = $h_time = __('Unpublished'); 68 } else { 69 if ( 'modified' == $column_name ) { 70 $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); 71 $m_time = $post->post_modified; 72 $time = get_post_modified_time('G', true); 73 } else { 74 $t_time = get_the_time(__('Y/m/d g:i:s A')); 75 $m_time = $post->post_date; 76 $time = get_post_time('G', true); 77 } 78 if ( ( abs(time() - $time) ) < 86400 ) { 79 if ( ( 'future' == $post->post_status) ) 80 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); 81 else 82 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); 83 } else { 84 $h_time = mysql2date(__('Y/m/d'), $m_time); 85 } 86 } 87 88 if ( 'excerpt' == $mode ) : ?> 89 <td><?php echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode) ?></td> 90 <?php else : ?> 91 <td><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) ?></abbr></td> 92 <?php endif; 93 break; 94 case 'title': 95 ?> 96 <td class="post-title"><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> 97 <?php 98 if ( !empty($post->post_password) ) { _e(' — <strong>Protected</strong>'); } elseif ('private' == $post->post_status) { _e(' — <strong>Private</strong>'); } 99 100 if ( 'excerpt' == $mode ) 101 the_excerpt(); 102 103 $actions = array(); 104 $actions['edit'] = '<a href="post.php?action=edit&post=' . $post->ID . '">' . __('Edit') . '</a>'; 105 $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 draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 106 $action_count = count($actions); 107 $i = 0; 108 foreach ( $actions as $action => $link ) { 109 ++$i; 110 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 111 echo "<span class='$action'>$link$sep</span>"; 112 } 113 ?> 114 </td> 115 <?php 116 break; 117 118 case 'categories': 119 ?> 120 <td><?php 121 $categories = get_the_category(); 122 if ( !empty( $categories ) ) { 123 $out = array(); 124 foreach ( $categories as $c ) 125 $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; 126 echo join( ', ', $out ); 127 } else { 128 _e('Uncategorized'); 129 } 130 ?></td> 131 <?php 132 break; 133 134 case 'tags': 135 ?> 136 <td><?php 137 $tags = get_the_tags(); 138 if ( !empty( $tags ) ) { 139 $out = array(); 140 foreach ( $tags as $c ) 141 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; 142 echo join( ', ', $out ); 143 } else { 144 _e('No Tags'); 145 } 146 ?></td> 147 <?php 148 break; 149 150 case 'comments': 151 ?> 152 <td class="num"><div class="post-com-count-wrapper"> 153 <?php 154 $left = isset($comment_pending_count) ? $comment_pending_count[$post->ID] : 0; 155 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); 156 if ( $left ) 157 echo '<strong>'; 158 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>'); 159 if ( $left ) 160 echo '</strong>'; 161 ?> 162 </div></td> 163 <?php 164 break; 165 166 case 'author': 167 ?> 168 <td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td> 169 <?php 170 break; 171 172 case 'status': 173 ?> 174 <td> 175 <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink"> 176 <?php 177 switch ( $post->post_status ) { 178 case 'publish' : 179 case 'private' : 180 _e('Published'); 181 break; 182 case 'future' : 183 _e('Scheduled'); 184 break; 185 case 'pending' : 186 _e('Pending Review'); 187 break; 188 case 'draft' : 189 _e('Unpublished'); 190 break; 191 } 192 ?> 193 </a> 194 </td> 195 <?php 196 break; 197 198 case 'control_view': 199 ?> 200 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td> 201 <?php 202 break; 203 204 case 'control_edit': 205 ?> 206 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td> 207 <?php 208 break; 209 210 case 'control_delete': 211 ?> 212 <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> 213 <?php 214 break; 215 216 default: 217 ?> 218 <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td> 219 <?php 220 break; 221 } 222 } 223 ?> 224 </tr> 225 <?php 226 endwhile; 32 post_rows(); 227 33 } else { 228 34 ?> 229 <tr style='background-color: <?php echo $bgcolor; ?>'>35 <tr> 230 36 <td colspan="8"><?php _e('No posts found.') ?></td> 231 37 </tr> -
trunk/wp-admin/includes/template.php
r8726 r8729 405 405 406 406 return $posts_columns; 407 } 408 409 function post_rows() { 410 global $wp_query, $post, $mode; 411 412 add_filter('the_title','wp_specialchars'); 413 414 // Create array of post IDs. 415 $post_ids = array(); 416 foreach ( $wp_query->posts as $a_post ) 417 $post_ids[] = $a_post->ID; 418 419 $comment_pending_count = get_pending_comments_num($post_ids); 420 if ( empty($comment_pending_count[$post->ID]) ) 421 $comment_pending_count = array(); 422 423 while ( have_posts() ) { 424 the_post(); 425 426 if ( empty($comment_pending_count[$post->ID]) ) 427 $comment_pending_count[$post->ID] = 0; 428 429 _post_row($post, $comment_pending_count[$post->ID], $mode); 430 } 431 } 432 433 function _post_row($a_post, $pending_comments, $mode) { 434 global $post; 435 static $class; 436 437 $global_post = $post; 438 $post = $a_post; 439 440 $class = 'alternate' == $class ? '' : 'alternate'; 441 global $current_user; 442 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); 443 $edit_link = get_edit_post_link( $post->ID ); 444 $title = get_the_title(); 445 if ( empty($title) ) 446 $title = __('(no title)'); 447 ?> 448 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top"> 449 <?php 450 $posts_columns = wp_manage_posts_columns(); 451 foreach($posts_columns as $column_name=>$column_display_name) { 452 453 switch($column_name) { 454 455 case 'cb': 456 ?> 457 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> 458 <?php 459 break; 460 461 case 'modified': 462 case 'date': 463 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { 464 $t_time = $h_time = __('Unpublished'); 465 } else { 466 if ( 'modified' == $column_name ) { 467 $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); 468 $m_time = $post->post_modified; 469 $time = get_post_modified_time('G', true); 470 } else { 471 $t_time = get_the_time(__('Y/m/d g:i:s A')); 472 $m_time = $post->post_date; 473 $time = get_post_time('G', true); 474 } 475 if ( ( abs(time() - $time) ) < 86400 ) { 476 if ( ( 'future' == $post->post_status) ) 477 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); 478 else 479 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); 480 } else { 481 $h_time = mysql2date(__('Y/m/d'), $m_time); 482 } 483 } 484 485 if ( 'excerpt' == $mode ) { ?> 486 <td><?php echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode) ?></td> 487 <?php } else { ?> 488 <td><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) ?></abbr></td> 489 <?php } 490 break; 491 492 case 'title': 493 ?> 494 <td class="post-title"><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> 495 <?php 496 if ( !empty($post->post_password) ) { _e(' — <strong>Protected</strong>'); } elseif ('private' == $post->post_status) { _e(' — <strong>Private</strong>'); } 497 498 if ( 'excerpt' == $mode ) 499 the_excerpt(); 500 501 $actions = array(); 502 $actions['edit'] = '<a href="post.php?action=edit&post=' . $post->ID . '">' . __('Edit') . '</a>'; 503 $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 draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 504 $action_count = count($actions); 505 $i = 0; 506 foreach ( $actions as $action => $link ) { 507 ++$i; 508 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 509 echo "<span class='$action'>$link$sep</span>"; 510 } 511 ?> 512 </td> 513 <?php 514 break; 515 516 case 'categories': 517 ?> 518 <td><?php 519 $categories = get_the_category(); 520 if ( !empty( $categories ) ) { 521 $out = array(); 522 foreach ( $categories as $c ) 523 $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; 524 echo join( ', ', $out ); 525 } else { 526 _e('Uncategorized'); 527 } 528 ?></td> 529 <?php 530 break; 531 532 case 'tags': 533 ?> 534 <td><?php 535 $tags = get_the_tags(); 536 if ( !empty( $tags ) ) { 537 $out = array(); 538 foreach ( $tags as $c ) 539 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; 540 echo join( ', ', $out ); 541 } else { 542 _e('No Tags'); 543 } 544 ?></td> 545 <?php 546 break; 547 548 case 'comments': 549 ?> 550 <td class="num"><div class="post-com-count-wrapper"> 551 <?php 552 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) ); 553 if ( $pending_comments ) 554 echo '<strong>'; 555 comments_number("<a href='edit.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); 556 if ( $pending_comments ) 557 echo '</strong>'; 558 ?> 559 </div></td> 560 <?php 561 break; 562 563 case 'author': 564 ?> 565 <td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td> 566 <?php 567 break; 568 569 case 'status': 570 ?> 571 <td> 572 <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink"> 573 <?php 574 switch ( $post->post_status ) { 575 case 'publish' : 576 case 'private' : 577 _e('Published'); 578 break; 579 case 'future' : 580 _e('Scheduled'); 581 break; 582 case 'pending' : 583 _e('Pending Review'); 584 break; 585 case 'draft' : 586 _e('Unpublished'); 587 break; 588 } 589 ?> 590 </a> 591 </td> 592 <?php 593 break; 594 595 case 'control_view': 596 ?> 597 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td> 598 <?php 599 break; 600 601 case 'control_edit': 602 ?> 603 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td> 604 <?php 605 break; 606 607 case 'control_delete': 608 ?> 609 <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> 610 <?php 611 break; 612 613 default: 614 ?> 615 <td><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td> 616 <?php 617 break; 618 } 619 } 620 ?> 621 </tr> 622 <?php 623 $post = $global_post; 407 624 } 408 625
Note: See TracChangeset
for help on using the changeset viewer.