3 * Posts List Table class.
6 * @subpackage List_Table
10 class WP_Posts_List_Table extends WP_List_Table {
13 * Whether the items should be displayed hierarchically or linearly
19 protected $hierarchical_display;
22 * Holds the number of pending comments for each post
28 protected $comment_pending_count;
31 * Holds the number of posts for this user
37 private $user_posts_count;
40 * Holds the number of posts which are sticky.
46 private $sticky_posts_count = 0;
54 * @see WP_List_Table::__construct() for more information on default arguments.
56 * @param array $args An associative array of arguments.
58 public function __construct( $args = array() ) {
59 global $post_type_object, $wpdb;
61 parent::__construct( array(
63 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
66 $post_type = $this->screen->post_type;
67 $post_type_object = get_post_type_object( $post_type );
69 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
70 $exclude_states = get_post_stati( array( 'show_in_admin_all_list' => false ) );
71 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
72 SELECT COUNT( 1 ) FROM $wpdb->posts
73 WHERE post_type = %s AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
75 ", $post_type, get_current_user_id() ) );
77 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) )
78 $_GET['author'] = get_current_user_id();
81 if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
82 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
83 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) );
87 public function ajax_user_can() {
88 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
91 public function prepare_items() {
92 global $avail_post_stati, $wp_query, $per_page, $mode;
94 $avail_post_stati = wp_edit_posts_query();
96 $this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
98 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
100 $post_type = $this->screen->post_type;
101 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
103 /** This filter is documented in wp-admin/includes/post.php */
104 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
106 if ( $this->hierarchical_display )
107 $total_pages = ceil( $total_items / $per_page );
109 $total_pages = $wp_query->max_num_pages;
111 if ( ! empty( $_REQUEST['mode'] ) ) {
112 $mode = $_REQUEST['mode'] == 'excerpt' ? 'excerpt' : 'list';
113 set_user_setting ( 'posts_list_mode', $mode );
115 $mode = get_user_setting ( 'posts_list_mode', 'list' );
118 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
120 $this->set_pagination_args( array(
121 'total_items' => $total_items,
122 'total_pages' => $total_pages,
123 'per_page' => $per_page
127 public function has_items() {
131 public function no_items() {
132 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
133 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
135 echo get_post_type_object( $this->screen->post_type )->labels->not_found;
138 protected function get_views() {
139 global $locked_post_status, $avail_post_stati;
141 $post_type = $this->screen->post_type;
143 if ( !empty($locked_post_status) )
146 $status_links = array();
147 $num_posts = wp_count_posts( $post_type, 'readable' );
151 $current_user_id = get_current_user_id();
153 if ( $this->user_posts_count ) {
154 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
155 $class = ' class="current"';
156 $status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
157 $allposts = '&all_posts=1';
160 $total_posts = array_sum( (array) $num_posts );
162 // Subtract post types that are not included in the admin all list.
163 foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
164 $total_posts -= $num_posts->$state;
166 $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
167 $status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
169 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
172 $status_name = $status->name;
174 if ( !in_array( $status_name, $avail_post_stati ) )
177 if ( empty( $num_posts->$status_name ) )
180 if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
181 $class = ' class="current"';
183 $status_links[$status_name] = "<a href='edit.php?post_status=$status_name&post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
186 if ( ! empty( $this->sticky_posts_count ) ) {
187 $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
189 $sticky_link = array( 'sticky' => "<a href='edit.php?post_type=$post_type&show_sticky=1'$class>" . sprintf( _nx( 'Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '</a>' );
191 // Sticky comes after Publish, or if not listed, after All.
192 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
193 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
196 return $status_links;
199 protected function get_bulk_actions() {
202 if ( $this->is_trash )
203 $actions['untrash'] = __( 'Restore' );
205 $actions['edit'] = __( 'Edit' );
207 if ( $this->is_trash || !EMPTY_TRASH_DAYS )
208 $actions['delete'] = __( 'Delete Permanently' );
210 $actions['trash'] = __( 'Move to Trash' );
215 protected function extra_tablenav( $which ) {
218 <div class="alignleft actions">
220 if ( 'top' == $which && !is_singular() ) {
222 $this->months_dropdown( $this->screen->post_type );
224 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
225 $dropdown_options = array(
226 'show_option_all' => __( 'View all categories' ),
233 wp_dropdown_categories( $dropdown_options );
237 * Fires before the Filter button on the Posts and Pages list tables.
239 * The Filter button allows sorting by date and/or category on the
240 * Posts list table, and sorting by date on the Pages list table.
244 do_action( 'restrict_manage_posts' );
246 submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
249 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
250 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
257 public function current_action() {
258 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
261 return parent::current_action();
264 protected function pagination( $which ) {
267 parent::pagination( $which );
269 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
270 $this->view_switcher( $mode );
273 protected function get_table_classes() {
274 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
277 public function get_columns() {
278 $post_type = $this->screen->post_type;
280 $posts_columns = array();
282 $posts_columns['cb'] = '<input type="checkbox" />';
284 /* translators: manage posts column name */
285 $posts_columns['title'] = _x( 'Title', 'column name' );
287 if ( post_type_supports( $post_type, 'author' ) ) {
288 $posts_columns['author'] = __( 'Author' );
291 $taxonomies = get_object_taxonomies( $post_type, 'objects' );
292 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
295 * Filter the taxonomy columns in the Posts list table.
297 * The dynamic portion of the hook name, $post_type, refers to the post
302 * @param array $taxonomies Array of taxonomies to show columns for.
303 * @param string $post_type The post type.
305 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
306 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
308 foreach ( $taxonomies as $taxonomy ) {
309 if ( 'category' == $taxonomy )
310 $column_key = 'categories';
311 elseif ( 'post_tag' == $taxonomy )
312 $column_key = 'tags';
314 $column_key = 'taxonomy-' . $taxonomy;
316 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
319 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
320 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
321 $posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></span></span>';
323 $posts_columns['date'] = __( 'Date' );
325 if ( 'page' == $post_type ) {
328 * Filter the columns displayed in the Pages list table.
332 * @param array $post_columns An array of column names.
334 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
338 * Filter the columns displayed in the Posts list table.
342 * @param array $posts_columns An array of column names.
343 * @param string $post_type The post type slug.
345 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
349 * Filter the columns displayed in the Posts list table for a specific post type.
351 * The dynamic portion of the hook name, $post_type, refers to the post type slug.
355 * @param array $post_columns An array of column names.
357 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
359 return $posts_columns;
362 protected function get_sortable_columns() {
365 'parent' => 'parent',
366 'comments' => 'comment_count',
367 'date' => array( 'date', true )
371 public function display_rows( $posts = array(), $level = 0 ) {
372 global $wp_query, $per_page;
374 if ( empty( $posts ) )
375 $posts = $wp_query->posts;
377 add_filter( 'the_title', 'esc_html' );
379 if ( $this->hierarchical_display ) {
380 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
382 $this->_display_rows( $posts, $level );
386 private function _display_rows( $posts, $level = 0 ) {
389 // Create array of post IDs.
392 foreach ( $posts as $a_post )
393 $post_ids[] = $a_post->ID;
395 $this->comment_pending_count = get_pending_comments_num( $post_ids );
397 foreach ( $posts as $post )
398 $this->single_row( $post, $level );
401 private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
407 $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
414 * Arrange pages into two parts: top level pages and children_pages
415 * children_pages is two dimensional array, eg.
416 * children_pages[10][] contains all sub-pages whose parent is 10.
417 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
418 * If searching, ignore hierarchy and treat everything as top level
420 if ( empty( $_REQUEST['s'] ) ) {
422 $top_level_pages = array();
423 $children_pages = array();
425 foreach ( $pages as $page ) {
427 // Catch and repair bad pages.
428 if ( $page->post_parent == $page->ID ) {
429 $page->post_parent = 0;
430 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
431 clean_post_cache( $page );
434 if ( 0 == $page->post_parent )
435 $top_level_pages[] = $page;
437 $children_pages[ $page->post_parent ][] = $page;
440 $pages = &$top_level_pages;
444 $start = ( $pagenum - 1 ) * $per_page;
445 $end = $start + $per_page;
447 foreach ( $pages as $page ) {
448 if ( $count >= $end )
451 if ( $count >= $start ) {
453 $this->single_row( $page, $level );
458 if ( isset( $children_pages ) )
459 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
462 // If it is the last pagenum and there are orphaned pages, display them with paging as well.
463 if ( isset( $children_pages ) && $count < $end ){
464 foreach ( $children_pages as $orphans ){
465 foreach ( $orphans as $op ) {
466 if ( $count >= $end )
469 if ( $count >= $start ) {
471 $this->single_row( $op, 0 );
481 * Given a top level page ID, display the nested hierarchy of sub-pages
482 * together with paging support
484 * @since 3.1.0 (Standalone function exists since 2.6.0)
486 * @param array $children_pages
490 * @param int $pagenum
491 * @param int $per_page
493 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
495 if ( ! isset( $children_pages[$parent] ) )
498 $start = ( $pagenum - 1 ) * $per_page;
499 $end = $start + $per_page;
501 foreach ( $children_pages[$parent] as $page ) {
503 if ( $count >= $end )
506 // If the page starts in a subtree, print the parents.
507 if ( $count == $start && $page->post_parent > 0 ) {
508 $my_parents = array();
509 $my_parent = $page->post_parent;
510 while ( $my_parent ) {
511 $my_parent = get_post( $my_parent );
512 $my_parents[] = $my_parent;
513 if ( !$my_parent->post_parent )
515 $my_parent = $my_parent->post_parent;
517 $num_parents = count( $my_parents );
518 while ( $my_parent = array_pop( $my_parents ) ) {
520 $this->single_row( $my_parent, $level - $num_parents );
525 if ( $count >= $start ) {
527 $this->single_row( $page, $level );
532 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
535 unset( $children_pages[$parent] ); //required in order to keep track of orphans
538 public function single_row( $post, $level = 0 ) {
542 $global_post = get_post();
543 $GLOBALS['post'] = $post;
544 setup_postdata( $post );
546 $edit_link = get_edit_post_link( $post->ID );
547 $title = _draft_or_post_title();
548 $post_type_object = get_post_type_object( $post->post_type );
549 $can_edit_post = current_user_can( 'edit_post', $post->ID );
551 $alternate = 'alternate' == $alternate ? '' : 'alternate';
552 $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
554 $lock_holder = wp_check_post_lock( $post->ID );
555 if ( $lock_holder ) {
556 $classes .= ' wp-locked';
557 $lock_holder = get_userdata( $lock_holder );
560 if ( $post->post_parent ) {
561 $count = count( get_post_ancestors( $post->ID ) );
562 $classes .= ' level-'. $count;
564 $classes .= ' level-0';
567 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
570 list( $columns, $hidden ) = $this->get_column_info();
572 foreach ( $columns as $column_name => $column_display_name ) {
573 $class = "class=\"$column_name column-$column_name\"";
576 if ( in_array( $column_name, $hidden ) )
577 $style = ' style="display:none;"';
579 $attributes = "$class$style";
581 switch ( $column_name ) {
585 <th scope="row" class="check-column">
587 if ( $can_edit_post ) {
590 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
591 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
592 <div class="locked-indicator"></div>
601 $attributes = 'class="post-title page-title column-title"' . $style;
602 if ( $this->hierarchical_display ) {
603 if ( 0 == $level && (int) $post->post_parent > 0 ) {
604 // Sent level 0 by accident, by default, or because we don't know the actual level.
605 $find_main_page = (int) $post->post_parent;
606 while ( $find_main_page > 0 ) {
607 $parent = get_post( $find_main_page );
609 if ( is_null( $parent ) )
613 $find_main_page = (int) $parent->post_parent;
615 if ( !isset( $parent_name ) ) {
616 /** This filter is documented in wp-includes/post-template.php */
617 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
623 $pad = str_repeat( '— ', $level );
624 echo "<td $attributes><strong>";
626 if ( $format = get_post_format( $post->ID ) ) {
627 $label = get_post_format_string( $format );
629 echo '<a href="' . esc_url( add_query_arg( array( 'post_format' => $format, 'post_type' => $post->post_type ), 'edit.php' ) ) . '" class="post-state-format post-format-icon post-format-' . $format . '" title="' . $label . '">' . $label . ":</a> ";
632 if ( $can_edit_post && $post->post_status != 'trash' ) {
633 echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
637 _post_states( $post );
639 if ( isset( $parent_name ) )
640 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
644 if ( $can_edit_post && $post->post_status != 'trash' ) {
645 if ( $lock_holder ) {
646 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
647 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
649 $locked_avatar = $locked_text = '';
652 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
655 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
659 if ( $can_edit_post && 'trash' != $post->post_status ) {
660 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
661 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
663 if ( current_user_can( 'delete_post', $post->ID ) ) {
664 if ( 'trash' == $post->post_status )
665 $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
666 elseif ( EMPTY_TRASH_DAYS )
667 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
668 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
669 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
671 if ( $post_type_object->public ) {
672 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
673 if ( $can_edit_post ) {
674 $preview_link = set_url_scheme( get_permalink( $post->ID ) );
675 /** This filter is documented in wp-admin/includes/meta-boxes.php */
676 $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
677 $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
679 } elseif ( 'trash' != $post->post_status ) {
680 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
684 if ( is_post_type_hierarchical( $post->post_type ) ) {
687 * Filter the array of row action links on the Pages list table.
689 * The filter is evaluated only for hierarchical post types.
693 * @param array $actions An array of row action links. Defaults are
694 * 'Edit', 'Quick Edit', 'Restore, 'Trash',
695 * 'Delete Permanently', 'Preview', and 'View'.
696 * @param WP_Post $post The post object.
698 $actions = apply_filters( 'page_row_actions', $actions, $post );
702 * Filter the array of row action links on the Posts list table.
704 * The filter is evaluated only for non-hierarchical post types.
708 * @param array $actions An array of row action links. Defaults are
709 * 'Edit', 'Quick Edit', 'Restore, 'Trash',
710 * 'Delete Permanently', 'Preview', and 'View'.
711 * @param WP_Post $post The post object.
713 $actions = apply_filters( 'post_row_actions', $actions, $post );
716 echo $this->row_actions( $actions );
718 get_inline_data( $post );
723 if ( '0000-00-00 00:00:00' == $post->post_date ) {
724 $t_time = $h_time = __( 'Unpublished' );
727 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
728 $m_time = $post->post_date;
729 $time = get_post_time( 'G', true, $post );
731 $time_diff = time() - $time;
733 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
734 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
736 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
739 echo '<td ' . $attributes . '>';
740 if ( 'excerpt' == $mode ) {
743 * Filter the published time of the post.
745 * If $mode equals 'excerpt', the published time and date are both displayed.
746 * If $mode equals 'list' (default), the publish date is displayed, with the
747 * time and date together available as an abbreviation definition.
751 * @param array $t_time The published time.
752 * @param WP_Post $post Post object.
753 * @param string $column_name The column name.
754 * @param string $mode The list display mode ('excerpt' or 'list').
756 echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
759 /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
760 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
763 if ( 'publish' == $post->post_status ) {
765 } elseif ( 'future' == $post->post_status ) {
766 if ( $time_diff > 0 )
767 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
771 _e( 'Last Modified' );
778 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
780 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
782 $this->comments_bubble( $post->ID, $pending_comments );
790 <td <?php echo $attributes ?>><?php
791 printf( '<a href="%s">%s</a>',
792 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
800 if ( 'categories' == $column_name )
801 $taxonomy = 'category';
802 elseif ( 'tags' == $column_name )
803 $taxonomy = 'post_tag';
804 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
805 $taxonomy = substr( $column_name, 9 );
810 $taxonomy_object = get_taxonomy( $taxonomy );
811 echo '<td ' . $attributes . '>';
812 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
814 foreach ( $terms as $t ) {
815 $posts_in_term_qv = array();
816 if ( 'post' != $post->post_type )
817 $posts_in_term_qv['post_type'] = $post->post_type;
818 if ( $taxonomy_object->query_var ) {
819 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
821 $posts_in_term_qv['taxonomy'] = $taxonomy;
822 $posts_in_term_qv['term'] = $t->slug;
825 $out[] = sprintf( '<a href="%s">%s</a>',
826 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
827 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
830 /* translators: used between list items, there is a space after the comma */
831 echo join( __( ', ' ), $out );
839 <td <?php echo $attributes ?>><?php
840 if ( is_post_type_hierarchical( $post->post_type ) ) {
843 * Fires in each custom column on the Posts list table.
845 * This hook only fires if the current post type is hierarchical,
850 * @param string $column_name The name of the column to display.
851 * @param int $post_id The current post ID.
853 do_action( 'manage_pages_custom_column', $column_name, $post->ID );
857 * Fires in each custom column in the Posts list table.
859 * This hook only fires if the current post type is non-hierarchical,
864 * @param string $column_name The name of the column to display.
865 * @param int $post_id The current post ID.
867 do_action( 'manage_posts_custom_column', $column_name, $post->ID );
871 * Fires for each custom column of a specific post type in the Posts list table.
873 * The dynamic portion of the hook name, $post->post_type, refers to the post type.
877 * @param string $column_name The name of the column to display.
878 * @param int $post_id The current post ID.
880 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
889 $GLOBALS['post'] = $global_post;
893 * Outputs the hidden row displayed when inline editing
897 public function inline_edit() {
900 $screen = $this->screen;
902 $post = get_default_post_to_edit( $screen->post_type );
903 $post_type_object = get_post_type_object( $screen->post_type );
905 $taxonomy_names = get_object_taxonomies( $screen->post_type );
906 $hierarchical_taxonomies = array();
907 $flat_taxonomies = array();
908 foreach ( $taxonomy_names as $taxonomy_name ) {
909 $taxonomy = get_taxonomy( $taxonomy_name );
911 if ( !$taxonomy->show_ui )
914 if ( $taxonomy->hierarchical )
915 $hierarchical_taxonomies[] = $taxonomy;
917 $flat_taxonomies[] = $taxonomy;
920 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
921 $can_publish = current_user_can( $post_type_object->cap->publish_posts );
922 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
926 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
928 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
930 while ( $bulk < 2 ) { ?>
932 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
933 echo $bulk ? " bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
934 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
936 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
937 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
940 if ( post_type_supports( $screen->post_type, 'title' ) ) :
942 <div id="bulk-title-div">
943 <div id="bulk-titles"></div>
946 <?php else : // $bulk ?>
949 <span class="title"><?php _e( 'Title' ); ?></span>
950 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
954 <span class="title"><?php _e( 'Slug' ); ?></span>
955 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
958 <?php endif; // $bulk
959 endif; // post_type_supports title ?>
961 <?php if ( !$bulk ) : ?>
962 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
963 <div class="inline-edit-date">
964 <?php touch_time( 1, 1, 0, 1 ); ?>
967 <?php endif; // $bulk
969 if ( post_type_supports( $screen->post_type, 'author' ) ) :
970 $authors_dropdown = '';
972 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
974 'hide_if_only_one_author' => false,
976 'name' => 'post_author',
982 $users_opt['show_option_none'] = __( '— No Change —' );
984 if ( $authors = wp_dropdown_users( $users_opt ) ) :
985 $authors_dropdown = '<label class="inline-edit-author">';
986 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
987 $authors_dropdown .= $authors;
988 $authors_dropdown .= '</label>';
993 <?php if ( !$bulk ) echo $authors_dropdown;
994 endif; // post_type_supports author
996 if ( !$bulk && $can_publish ) :
999 <div class="inline-edit-group">
1000 <label class="alignleft">
1001 <span class="title"><?php _e( 'Password' ); ?></span>
1002 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1005 <em style="margin:5px 10px 0 0" class="alignleft">
1007 /* translators: Between password field and private checkbox on post quick edit interface */
1008 echo __( '–OR–' );
1011 <label class="alignleft inline-edit-private">
1012 <input type="checkbox" name="keep_private" value="private" />
1013 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
1021 <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
1023 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1025 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
1027 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1028 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
1029 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
1030 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
1033 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
1037 <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
1039 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1042 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1043 echo $authors_dropdown;
1045 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1047 if ( $post_type_object->hierarchical ) :
1050 <span class="title"><?php _e( 'Parent' ); ?></span>
1052 $dropdown_args = array(
1053 'post_type' => $post_type_object->name,
1054 'selected' => $post->post_parent,
1055 'name' => 'post_parent',
1056 'show_option_none' => __( 'Main Page (no parent)' ),
1057 'option_none_value' => 0,
1058 'sort_column' => 'menu_order, post_title',
1062 $dropdown_args['show_option_no_change'] = __( '— No Change —' );
1065 * Filter the arguments used to generate the Quick Edit page-parent drop-down.
1069 * @see wp_dropdown_pages()
1071 * @param array $dropdown_args An array of arguments.
1073 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
1075 wp_dropdown_pages( $dropdown_args );
1080 endif; // hierarchical
1085 <span class="title"><?php _e( 'Order' ); ?></span>
1086 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1089 <?php endif; // !$bulk
1091 if ( 'page' == $screen->post_type ) :
1095 <span class="title"><?php _e( 'Template' ); ?></span>
1096 <select name="page_template">
1097 <?php if ( $bulk ) : ?>
1098 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1099 <?php endif; // $bulk ?>
1100 <option value="default"><?php _e( 'Default Template' ); ?></option>
1101 <?php page_template_dropdown() ?>
1106 endif; // page post_type
1107 endif; // page-attributes
1110 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
1112 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
1113 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
1114 <label class="inline-edit-tags">
1115 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1116 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
1120 <?php endforeach; //$flat_taxonomies as $taxonomy ?>
1122 <?php endif; // count( $flat_taxonomies ) && !$bulk ?>
1124 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
1127 <div class="inline-edit-group">
1128 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1129 <label class="alignleft">
1130 <span class="title"><?php _e( 'Comments' ); ?></span>
1131 <select name="comment_status">
1132 <option value=""><?php _e( '— No Change —' ); ?></option>
1133 <option value="open"><?php _e( 'Allow' ); ?></option>
1134 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1137 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1138 <label class="alignright">
1139 <span class="title"><?php _e( 'Pings' ); ?></span>
1140 <select name="ping_status">
1141 <option value=""><?php _e( '— No Change —' ); ?></option>
1142 <option value="open"><?php _e( 'Allow' ); ?></option>
1143 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1149 <?php else : // $bulk ?>
1151 <div class="inline-edit-group">
1152 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1153 <label class="alignleft">
1154 <input type="checkbox" name="comment_status" value="open" />
1155 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1157 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1158 <label class="alignleft">
1159 <input type="checkbox" name="ping_status" value="open" />
1160 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1165 <?php endif; // $bulk
1166 endif; // post_type_supports comments or pings ?>
1168 <div class="inline-edit-group">
1169 <label class="inline-edit-status alignleft">
1170 <span class="title"><?php _e( 'Status' ); ?></span>
1171 <select name="_status">
1172 <?php if ( $bulk ) : ?>
1173 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1174 <?php endif; // $bulk ?>
1175 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1176 <option value="publish"><?php _e( 'Published' ); ?></option>
1177 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1178 <?php if ( $bulk ) : ?>
1179 <option value="private"><?php _e( 'Private' ) ?></option>
1180 <?php endif; // $bulk ?>
1182 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1183 <option value="draft"><?php _e( 'Draft' ); ?></option>
1187 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1189 <?php if ( $bulk ) : ?>
1191 <label class="alignright">
1192 <span class="title"><?php _e( 'Sticky' ); ?></span>
1193 <select name="sticky">
1194 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1195 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1196 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1200 <?php else : // $bulk ?>
1202 <label class="alignleft">
1203 <input type="checkbox" name="sticky" value="sticky" />
1204 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1207 <?php endif; // $bulk ?>
1209 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1215 if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1216 $post_formats = get_theme_support( 'post-formats' );
1219 <label class="alignleft" for="post_format">
1220 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1221 <select name="post_format">
1222 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1223 <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
1226 foreach ( $post_formats[0] as $format ) {
1228 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
1243 list( $columns ) = $this->get_column_info();
1245 foreach ( $columns as $column_name => $column_display_name ) {
1246 if ( isset( $core_columns[$column_name] ) )
1252 * Fires once for each column in Bulk Edit mode.
1256 * @param string $column_name Name of the column to edit.
1257 * @param WP_Post $post_type The post type slug.
1259 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
1263 * Fires once for each column in Quick Edit mode.
1267 * @param string $column_name Name of the column to edit.
1268 * @param WP_Post $post_type The post type slug.
1270 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type );
1275 <p class="submit inline-edit-save">
1276 <a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
1277 <?php if ( ! $bulk ) {
1278 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1280 <a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
1281 <span class="spinner"></span>
1283 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
1285 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1286 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1287 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1288 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1290 <span class="error" style="display:none"></span>
1291 <br class="clear" />
1298 </tbody></table></form>