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() {
201 $post_type_obj = get_post_type_object( $this->screen->post_type );
203 if ( $this->is_trash ) {
204 $actions['untrash'] = __( 'Restore' );
206 $actions['edit'] = __( 'Edit' );
209 if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
210 if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
211 $actions['delete'] = __( 'Delete Permanently' );
213 $actions['trash'] = __( 'Move to Trash' );
222 * @param string $which
224 protected function extra_tablenav( $which ) {
227 <div class="alignleft actions">
229 if ( 'top' == $which && !is_singular() ) {
231 $this->months_dropdown( $this->screen->post_type );
233 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
234 $dropdown_options = array(
235 'show_option_all' => __( 'All categories' ),
243 echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
244 wp_dropdown_categories( $dropdown_options );
248 * Fires before the Filter button on the Posts and Pages list tables.
250 * The Filter button allows sorting by date and/or category on the
251 * Posts list table, and sorting by date on the Pages list table.
255 do_action( 'restrict_manage_posts' );
257 submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
260 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
261 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
268 public function current_action() {
269 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
272 return parent::current_action();
276 * @global string $mode
277 * @param string $which
279 protected function pagination( $which ) {
282 parent::pagination( $which );
284 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
285 $this->view_switcher( $mode );
288 protected function get_table_classes() {
289 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
292 public function get_columns() {
293 $post_type = $this->screen->post_type;
295 $posts_columns = array();
297 $posts_columns['cb'] = '<input type="checkbox" />';
299 /* translators: manage posts column name */
300 $posts_columns['title'] = _x( 'Title', 'column name' );
302 if ( post_type_supports( $post_type, 'author' ) ) {
303 $posts_columns['author'] = __( 'Author' );
306 $taxonomies = get_object_taxonomies( $post_type, 'objects' );
307 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
310 * Filter the taxonomy columns in the Posts list table.
312 * The dynamic portion of the hook name, `$post_type`, refers to the post
317 * @param array $taxonomies Array of taxonomies to show columns for.
318 * @param string $post_type The post type.
320 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
321 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
323 foreach ( $taxonomies as $taxonomy ) {
324 if ( 'category' == $taxonomy )
325 $column_key = 'categories';
326 elseif ( 'post_tag' == $taxonomy )
327 $column_key = 'tags';
329 $column_key = 'taxonomy-' . $taxonomy;
331 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
334 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
335 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
336 $posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></span></span>';
338 $posts_columns['date'] = __( 'Date' );
340 if ( 'page' == $post_type ) {
343 * Filter the columns displayed in the Pages list table.
347 * @param array $post_columns An array of column names.
349 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
353 * Filter the columns displayed in the Posts list table.
357 * @param array $posts_columns An array of column names.
358 * @param string $post_type The post type slug.
360 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
364 * Filter the columns displayed in the Posts list table for a specific post type.
366 * The dynamic portion of the hook name, `$post_type`, refers to the post type slug.
370 * @param array $post_columns An array of column names.
372 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
374 return $posts_columns;
377 protected function get_sortable_columns() {
380 'parent' => 'parent',
381 'comments' => 'comment_count',
382 'date' => array( 'date', true )
387 * @global WP_Query $wp_query
388 * @global int $per_page
389 * @param array $posts
392 public function display_rows( $posts = array(), $level = 0 ) {
393 global $wp_query, $per_page;
395 if ( empty( $posts ) )
396 $posts = $wp_query->posts;
398 add_filter( 'the_title', 'esc_html' );
400 if ( $this->hierarchical_display ) {
401 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
403 $this->_display_rows( $posts, $level );
408 * @global string $mode
409 * @param array $posts
412 private function _display_rows( $posts, $level = 0 ) {
415 // Create array of post IDs.
418 foreach ( $posts as $a_post )
419 $post_ids[] = $a_post->ID;
421 $this->comment_pending_count = get_pending_comments_num( $post_ids );
423 foreach ( $posts as $post )
424 $this->single_row( $post, $level );
429 * @param array $pages
430 * @param int $pagenum
431 * @param int $per_page
434 private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
440 $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
447 * Arrange pages into two parts: top level pages and children_pages
448 * children_pages is two dimensional array, eg.
449 * children_pages[10][] contains all sub-pages whose parent is 10.
450 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
451 * If searching, ignore hierarchy and treat everything as top level
453 if ( empty( $_REQUEST['s'] ) ) {
455 $top_level_pages = array();
456 $children_pages = array();
458 foreach ( $pages as $page ) {
460 // Catch and repair bad pages.
461 if ( $page->post_parent == $page->ID ) {
462 $page->post_parent = 0;
463 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
464 clean_post_cache( $page );
467 if ( 0 == $page->post_parent )
468 $top_level_pages[] = $page;
470 $children_pages[ $page->post_parent ][] = $page;
473 $pages = &$top_level_pages;
477 $start = ( $pagenum - 1 ) * $per_page;
478 $end = $start + $per_page;
480 foreach ( $pages as $page ) {
481 if ( $count >= $end )
484 if ( $count >= $start ) {
486 $this->single_row( $page, $level );
491 if ( isset( $children_pages ) )
492 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
495 // If it is the last pagenum and there are orphaned pages, display them with paging as well.
496 if ( isset( $children_pages ) && $count < $end ){
497 foreach ( $children_pages as $orphans ){
498 foreach ( $orphans as $op ) {
499 if ( $count >= $end )
502 if ( $count >= $start ) {
504 $this->single_row( $op, 0 );
514 * Given a top level page ID, display the nested hierarchy of sub-pages
515 * together with paging support
517 * @since 3.1.0 (Standalone function exists since 2.6.0)
519 * @param array $children_pages
523 * @param int $pagenum
524 * @param int $per_page
526 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
528 if ( ! isset( $children_pages[$parent] ) )
531 $start = ( $pagenum - 1 ) * $per_page;
532 $end = $start + $per_page;
534 foreach ( $children_pages[$parent] as $page ) {
536 if ( $count >= $end )
539 // If the page starts in a subtree, print the parents.
540 if ( $count == $start && $page->post_parent > 0 ) {
541 $my_parents = array();
542 $my_parent = $page->post_parent;
543 while ( $my_parent ) {
544 $my_parent = get_post( $my_parent );
545 $my_parents[] = $my_parent;
546 if ( !$my_parent->post_parent )
548 $my_parent = $my_parent->post_parent;
550 $num_parents = count( $my_parents );
551 while ( $my_parent = array_pop( $my_parents ) ) {
553 $this->single_row( $my_parent, $level - $num_parents );
558 if ( $count >= $start ) {
560 $this->single_row( $page, $level );
565 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
568 unset( $children_pages[$parent] ); //required in order to keep track of orphans
572 * @global string $mode
573 * @staticvar string $alternate
574 * @param WP_Post $post
577 public function single_row( $post, $level = 0 ) {
581 $global_post = get_post();
582 $GLOBALS['post'] = $post;
583 setup_postdata( $post );
585 $edit_link = get_edit_post_link( $post->ID );
586 $title = _draft_or_post_title();
587 $post_type_object = get_post_type_object( $post->post_type );
588 $can_edit_post = current_user_can( 'edit_post', $post->ID );
590 $alternate = 'alternate' == $alternate ? '' : 'alternate';
591 $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
593 $lock_holder = wp_check_post_lock( $post->ID );
594 if ( $lock_holder ) {
595 $classes .= ' wp-locked';
596 $lock_holder = get_userdata( $lock_holder );
599 if ( $post->post_parent ) {
600 $count = count( get_post_ancestors( $post->ID ) );
601 $classes .= ' level-'. $count;
603 $classes .= ' level-0';
606 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
609 list( $columns, $hidden ) = $this->get_column_info();
611 foreach ( $columns as $column_name => $column_display_name ) {
612 $class = "class=\"$column_name column-$column_name\"";
615 if ( in_array( $column_name, $hidden ) )
616 $style = ' style="display:none;"';
618 $attributes = "$class$style";
620 switch ( $column_name ) {
624 <th scope="row" class="check-column">
626 if ( $can_edit_post ) {
629 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
630 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
631 <div class="locked-indicator"></div>
640 $attributes = 'class="post-title page-title column-title"' . $style;
641 if ( $this->hierarchical_display ) {
642 if ( 0 == $level && (int) $post->post_parent > 0 ) {
643 // Sent level 0 by accident, by default, or because we don't know the actual level.
644 $find_main_page = (int) $post->post_parent;
645 while ( $find_main_page > 0 ) {
646 $parent = get_post( $find_main_page );
648 if ( is_null( $parent ) )
652 $find_main_page = (int) $parent->post_parent;
654 if ( !isset( $parent_name ) ) {
655 /** This filter is documented in wp-includes/post-template.php */
656 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
662 $pad = str_repeat( '— ', $level );
663 echo "<td $attributes><strong>";
665 if ( $format = get_post_format( $post->ID ) ) {
666 $label = get_post_format_string( $format );
668 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> ";
671 if ( $can_edit_post && $post->post_status != 'trash' ) {
672 echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
676 _post_states( $post );
678 if ( isset( $parent_name ) )
679 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
683 if ( $can_edit_post && $post->post_status != 'trash' ) {
684 if ( $lock_holder ) {
685 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
686 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
688 $locked_avatar = $locked_text = '';
691 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
694 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
698 if ( $can_edit_post && 'trash' != $post->post_status ) {
699 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
700 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick Edit' ) . '</a>';
702 if ( current_user_can( 'delete_post', $post->ID ) ) {
703 if ( 'trash' == $post->post_status )
704 $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>";
705 elseif ( EMPTY_TRASH_DAYS )
706 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
707 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
708 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
710 if ( $post_type_object->public ) {
711 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
712 if ( $can_edit_post ) {
713 $preview_link = set_url_scheme( get_permalink( $post->ID ) );
714 /** This filter is documented in wp-admin/includes/meta-boxes.php */
715 $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
716 $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
718 } elseif ( 'trash' != $post->post_status ) {
719 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
723 if ( is_post_type_hierarchical( $post->post_type ) ) {
726 * Filter the array of row action links on the Pages list table.
728 * The filter is evaluated only for hierarchical post types.
732 * @param array $actions An array of row action links. Defaults are
733 * 'Edit', 'Quick Edit', 'Restore, 'Trash',
734 * 'Delete Permanently', 'Preview', and 'View'.
735 * @param WP_Post $post The post object.
737 $actions = apply_filters( 'page_row_actions', $actions, $post );
741 * Filter the array of row action links on the Posts list table.
743 * The filter is evaluated only for non-hierarchical post types.
747 * @param array $actions An array of row action links. Defaults are
748 * 'Edit', 'Quick Edit', 'Restore, 'Trash',
749 * 'Delete Permanently', 'Preview', and 'View'.
750 * @param WP_Post $post The post object.
752 $actions = apply_filters( 'post_row_actions', $actions, $post );
755 echo $this->row_actions( $actions );
757 get_inline_data( $post );
762 if ( '0000-00-00 00:00:00' == $post->post_date ) {
763 $t_time = $h_time = __( 'Unpublished' );
766 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
767 $m_time = $post->post_date;
768 $time = get_post_time( 'G', true, $post );
770 $time_diff = time() - $time;
772 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
773 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
775 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
778 echo '<td ' . $attributes . '>';
779 if ( 'excerpt' == $mode ) {
782 * Filter the published time of the post.
784 * If $mode equals 'excerpt', the published time and date are both displayed.
785 * If $mode equals 'list' (default), the publish date is displayed, with the
786 * time and date together available as an abbreviation definition.
790 * @param array $t_time The published time.
791 * @param WP_Post $post Post object.
792 * @param string $column_name The column name.
793 * @param string $mode The list display mode ('excerpt' or 'list').
795 echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
798 /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
799 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
802 if ( 'publish' == $post->post_status ) {
804 } elseif ( 'future' == $post->post_status ) {
805 if ( $time_diff > 0 )
806 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
810 _e( 'Last Modified' );
817 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
819 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
821 $this->comments_bubble( $post->ID, $pending_comments );
829 <td <?php echo $attributes ?>><?php
830 printf( '<a href="%s">%s</a>',
831 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
839 if ( 'categories' == $column_name )
840 $taxonomy = 'category';
841 elseif ( 'tags' == $column_name )
842 $taxonomy = 'post_tag';
843 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
844 $taxonomy = substr( $column_name, 9 );
849 $taxonomy_object = get_taxonomy( $taxonomy );
850 echo '<td ' . $attributes . '>';
851 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
853 foreach ( $terms as $t ) {
854 $posts_in_term_qv = array();
855 if ( 'post' != $post->post_type )
856 $posts_in_term_qv['post_type'] = $post->post_type;
857 if ( $taxonomy_object->query_var ) {
858 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
860 $posts_in_term_qv['taxonomy'] = $taxonomy;
861 $posts_in_term_qv['term'] = $t->slug;
864 $out[] = sprintf( '<a href="%s">%s</a>',
865 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
866 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
869 /* translators: used between list items, there is a space after the comma */
870 echo join( __( ', ' ), $out );
878 <td <?php echo $attributes ?>><?php
879 if ( is_post_type_hierarchical( $post->post_type ) ) {
882 * Fires in each custom column on the Posts list table.
884 * This hook only fires if the current post type is hierarchical,
889 * @param string $column_name The name of the column to display.
890 * @param int $post_id The current post ID.
892 do_action( 'manage_pages_custom_column', $column_name, $post->ID );
896 * Fires in each custom column in the Posts list table.
898 * This hook only fires if the current post type is non-hierarchical,
903 * @param string $column_name The name of the column to display.
904 * @param int $post_id The current post ID.
906 do_action( 'manage_posts_custom_column', $column_name, $post->ID );
910 * Fires for each custom column of a specific post type in the Posts list table.
912 * The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
916 * @param string $column_name The name of the column to display.
917 * @param int $post_id The current post ID.
919 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
928 $GLOBALS['post'] = $global_post;
932 * Outputs the hidden row displayed when inline editing
936 public function inline_edit() {
939 $screen = $this->screen;
941 $post = get_default_post_to_edit( $screen->post_type );
942 $post_type_object = get_post_type_object( $screen->post_type );
944 $taxonomy_names = get_object_taxonomies( $screen->post_type );
945 $hierarchical_taxonomies = array();
946 $flat_taxonomies = array();
947 foreach ( $taxonomy_names as $taxonomy_name ) {
948 $taxonomy = get_taxonomy( $taxonomy_name );
950 if ( !$taxonomy->show_ui )
953 if ( $taxonomy->hierarchical )
954 $hierarchical_taxonomies[] = $taxonomy;
956 $flat_taxonomies[] = $taxonomy;
959 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
960 $can_publish = current_user_can( $post_type_object->cap->publish_posts );
961 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
965 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
967 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
969 while ( $bulk < 2 ) { ?>
971 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
972 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}";
973 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
975 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
976 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
979 if ( post_type_supports( $screen->post_type, 'title' ) ) :
981 <div id="bulk-title-div">
982 <div id="bulk-titles"></div>
985 <?php else : // $bulk ?>
988 <span class="title"><?php _e( 'Title' ); ?></span>
989 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
993 <span class="title"><?php _e( 'Slug' ); ?></span>
994 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
997 <?php endif; // $bulk
998 endif; // post_type_supports title ?>
1000 <?php if ( !$bulk ) : ?>
1001 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
1002 <div class="inline-edit-date">
1003 <?php touch_time( 1, 1, 0, 1 ); ?>
1005 <br class="clear" />
1006 <?php endif; // $bulk
1008 if ( post_type_supports( $screen->post_type, 'author' ) ) :
1009 $authors_dropdown = '';
1011 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
1013 'hide_if_only_one_author' => false,
1015 'name' => 'post_author',
1016 'class'=> 'authors',
1021 $users_opt['show_option_none'] = __( '— No Change —' );
1023 if ( $authors = wp_dropdown_users( $users_opt ) ) :
1024 $authors_dropdown = '<label class="inline-edit-author">';
1025 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
1026 $authors_dropdown .= $authors;
1027 $authors_dropdown .= '</label>';
1032 <?php if ( !$bulk ) echo $authors_dropdown;
1033 endif; // post_type_supports author
1035 if ( !$bulk && $can_publish ) :
1038 <div class="inline-edit-group">
1039 <label class="alignleft">
1040 <span class="title"><?php _e( 'Password' ); ?></span>
1041 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1044 <em style="margin:5px 10px 0 0" class="alignleft">
1046 /* translators: Between password field and private checkbox on post quick edit interface */
1047 echo __( '–OR–' );
1050 <label class="alignleft inline-edit-private">
1051 <input type="checkbox" name="keep_private" value="private" />
1052 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
1060 <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
1062 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1064 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
1066 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1067 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
1068 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
1069 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
1072 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
1076 <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
1078 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1081 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1082 echo $authors_dropdown;
1084 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1086 if ( $post_type_object->hierarchical ) :
1089 <span class="title"><?php _e( 'Parent' ); ?></span>
1091 $dropdown_args = array(
1092 'post_type' => $post_type_object->name,
1093 'selected' => $post->post_parent,
1094 'name' => 'post_parent',
1095 'show_option_none' => __( 'Main Page (no parent)' ),
1096 'option_none_value' => 0,
1097 'sort_column' => 'menu_order, post_title',
1101 $dropdown_args['show_option_no_change'] = __( '— No Change —' );
1104 * Filter the arguments used to generate the Quick Edit page-parent drop-down.
1108 * @see wp_dropdown_pages()
1110 * @param array $dropdown_args An array of arguments.
1112 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
1114 wp_dropdown_pages( $dropdown_args );
1119 endif; // hierarchical
1124 <span class="title"><?php _e( 'Order' ); ?></span>
1125 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1128 <?php endif; // !$bulk
1130 if ( 'page' == $screen->post_type ) :
1134 <span class="title"><?php _e( 'Template' ); ?></span>
1135 <select name="page_template">
1136 <?php if ( $bulk ) : ?>
1137 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1138 <?php endif; // $bulk ?>
1140 /** This filter is documented in wp-admin/includes/meta-boxes.php */
1141 $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );
1143 <option value="default"><?php echo esc_html( $default_title ); ?></option>
1144 <?php page_template_dropdown() ?>
1149 endif; // page post_type
1150 endif; // page-attributes
1153 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
1155 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
1156 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
1157 <label class="inline-edit-tags">
1158 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1159 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
1163 <?php endforeach; //$flat_taxonomies as $taxonomy ?>
1165 <?php endif; // count( $flat_taxonomies ) && !$bulk ?>
1167 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
1170 <div class="inline-edit-group">
1171 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1172 <label class="alignleft">
1173 <span class="title"><?php _e( 'Comments' ); ?></span>
1174 <select name="comment_status">
1175 <option value=""><?php _e( '— No Change —' ); ?></option>
1176 <option value="open"><?php _e( 'Allow' ); ?></option>
1177 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1180 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1181 <label class="alignright">
1182 <span class="title"><?php _e( 'Pings' ); ?></span>
1183 <select name="ping_status">
1184 <option value=""><?php _e( '— No Change —' ); ?></option>
1185 <option value="open"><?php _e( 'Allow' ); ?></option>
1186 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1192 <?php else : // $bulk ?>
1194 <div class="inline-edit-group">
1195 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1196 <label class="alignleft">
1197 <input type="checkbox" name="comment_status" value="open" />
1198 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1200 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1201 <label class="alignleft">
1202 <input type="checkbox" name="ping_status" value="open" />
1203 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1208 <?php endif; // $bulk
1209 endif; // post_type_supports comments or pings ?>
1211 <div class="inline-edit-group">
1212 <label class="inline-edit-status alignleft">
1213 <span class="title"><?php _e( 'Status' ); ?></span>
1214 <select name="_status">
1215 <?php if ( $bulk ) : ?>
1216 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1217 <?php endif; // $bulk ?>
1218 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1219 <option value="publish"><?php _e( 'Published' ); ?></option>
1220 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1221 <?php if ( $bulk ) : ?>
1222 <option value="private"><?php _e( 'Private' ) ?></option>
1223 <?php endif; // $bulk ?>
1225 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1226 <option value="draft"><?php _e( 'Draft' ); ?></option>
1230 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1232 <?php if ( $bulk ) : ?>
1234 <label class="alignright">
1235 <span class="title"><?php _e( 'Sticky' ); ?></span>
1236 <select name="sticky">
1237 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1238 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1239 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1243 <?php else : // $bulk ?>
1245 <label class="alignleft">
1246 <input type="checkbox" name="sticky" value="sticky" />
1247 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1250 <?php endif; // $bulk ?>
1252 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1258 if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1259 $post_formats = get_theme_support( 'post-formats' );
1262 <label class="alignleft" for="post_format">
1263 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1264 <select name="post_format">
1265 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1266 <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
1269 foreach ( $post_formats[0] as $format ) {
1271 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
1286 list( $columns ) = $this->get_column_info();
1288 foreach ( $columns as $column_name => $column_display_name ) {
1289 if ( isset( $core_columns[$column_name] ) )
1295 * Fires once for each column in Bulk Edit mode.
1299 * @param string $column_name Name of the column to edit.
1300 * @param WP_Post $post_type The post type slug.
1302 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
1306 * Fires once for each column in Quick Edit mode.
1310 * @param string $column_name Name of the column to edit.
1311 * @param WP_Post $post_type The post type slug.
1313 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type );
1318 <p class="submit inline-edit-save">
1319 <a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
1320 <?php if ( ! $bulk ) {
1321 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1323 <a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
1324 <span class="spinner"></span>
1326 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
1328 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1329 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1330 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1331 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1333 <span class="error" style="display:none"></span>
1334 <br class="clear" />
1341 </tbody></table></form>