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 var $hierarchical_display;
22 * Holds the number of pending comments for each post
28 var $comment_pending_count;
31 * Holds the number of posts for this user
37 var $user_posts_count;
40 * Holds the number of posts which are sticky.
46 var $sticky_posts_count = 0;
48 function __construct( $args = array() ) {
49 global $post_type_object, $wpdb;
51 parent::__construct( array(
53 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
56 $post_type = $this->screen->post_type;
57 $post_type_object = get_post_type_object( $post_type );
59 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
60 $exclude_states = get_post_stati( array( 'show_in_admin_all_list' => false ) );
61 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
62 SELECT COUNT( 1 ) FROM $wpdb->posts
63 WHERE post_type = %s AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
65 ", $post_type, get_current_user_id() ) );
67 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) )
68 $_GET['author'] = get_current_user_id();
71 if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
72 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
73 $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 ) );
77 function ajax_user_can() {
78 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
81 function prepare_items() {
82 global $avail_post_stati, $wp_query, $per_page, $mode;
84 $avail_post_stati = wp_edit_posts_query();
86 $this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
88 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
90 $post_type = $this->screen->post_type;
91 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
93 /** This filter is documented in wp-admin/includes/post.php */
94 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
96 if ( $this->hierarchical_display )
97 $total_pages = ceil( $total_items / $per_page );
99 $total_pages = $wp_query->max_num_pages;
101 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
103 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
105 $this->set_pagination_args( array(
106 'total_items' => $total_items,
107 'total_pages' => $total_pages,
108 'per_page' => $per_page
112 function has_items() {
116 function no_items() {
117 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
118 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
120 echo get_post_type_object( $this->screen->post_type )->labels->not_found;
123 function get_views() {
124 global $locked_post_status, $avail_post_stati;
126 $post_type = $this->screen->post_type;
128 if ( !empty($locked_post_status) )
131 $status_links = array();
132 $num_posts = wp_count_posts( $post_type, 'readable' );
136 $current_user_id = get_current_user_id();
138 if ( $this->user_posts_count ) {
139 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
140 $class = ' class="current"';
141 $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>';
142 $allposts = '&all_posts=1';
145 $total_posts = array_sum( (array) $num_posts );
147 // Subtract post types that are not included in the admin all list.
148 foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
149 $total_posts -= $num_posts->$state;
151 $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
152 $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>';
154 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
157 $status_name = $status->name;
159 if ( !in_array( $status_name, $avail_post_stati ) )
162 if ( empty( $num_posts->$status_name ) )
165 if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
166 $class = ' class="current"';
168 $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>';
171 if ( ! empty( $this->sticky_posts_count ) ) {
172 $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
174 $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>' );
176 // Sticky comes after Publish, or if not listed, after All.
177 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
178 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
181 return $status_links;
184 function get_bulk_actions() {
187 if ( $this->is_trash )
188 $actions['untrash'] = __( 'Restore' );
190 $actions['edit'] = __( 'Edit' );
192 if ( $this->is_trash || !EMPTY_TRASH_DAYS )
193 $actions['delete'] = __( 'Delete Permanently' );
195 $actions['trash'] = __( 'Move to Trash' );
200 function extra_tablenav( $which ) {
203 <div class="alignleft actions">
205 if ( 'top' == $which && !is_singular() ) {
207 $this->months_dropdown( $this->screen->post_type );
209 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
210 $dropdown_options = array(
211 'show_option_all' => __( 'View all categories' ),
218 wp_dropdown_categories( $dropdown_options );
222 * Fires before the Filter button on the Posts and Pages list tables.
224 * The Filter button allows sorting by date and/or category on the
225 * Posts list table, and sorting by date on the Pages list table.
229 do_action( 'restrict_manage_posts' );
231 submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) );
234 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
235 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
242 function current_action() {
243 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
246 return parent::current_action();
249 function pagination( $which ) {
252 parent::pagination( $which );
254 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
255 $this->view_switcher( $mode );
258 function get_table_classes() {
259 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
262 function get_columns() {
263 $post_type = $this->screen->post_type;
265 $posts_columns = array();
267 $posts_columns['cb'] = '<input type="checkbox" />';
269 /* translators: manage posts column name */
270 $posts_columns['title'] = _x( 'Title', 'column name' );
272 if ( post_type_supports( $post_type, 'author' ) )
273 $posts_columns['author'] = __( 'Author' );
275 $taxonomies = array();
277 $taxonomies = get_object_taxonomies( $post_type, 'objects' );
278 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
281 * Filter the taxonomy columns in the Posts list table.
283 * The dynamic portion of the hook name, $post_type, refers to the post
288 * @param array $taxonomies Array of taxonomies to show columns for.
289 * @param string $post_type The post type.
291 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
292 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
294 foreach ( $taxonomies as $taxonomy ) {
295 if ( 'category' == $taxonomy )
296 $column_key = 'categories';
297 elseif ( 'post_tag' == $taxonomy )
298 $column_key = 'tags';
300 $column_key = 'taxonomy-' . $taxonomy;
302 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
305 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
306 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
307 $posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></span></span>';
309 $posts_columns['date'] = __( 'Date' );
311 if ( 'page' == $post_type ) {
314 * Filter the columns displayed in the Pages list table.
318 * @param array $post_columns An array of column names.
320 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
324 * Filter the columns displayed in the Posts list table.
328 * @param array $posts_columns An array of column names.
329 * @param string $post_type The post type slug.
331 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
335 * Filter the columns displayed in the Posts list table for a specific post type.
337 * The dynamic portion of the hook name, $post_type, refers to the post type slug.
341 * @param array $post_columns An array of column names.
343 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
345 return $posts_columns;
348 function get_sortable_columns() {
351 'parent' => 'parent',
352 'comments' => 'comment_count',
353 'date' => array( 'date', true )
357 function display_rows( $posts = array(), $level = 0 ) {
358 global $wp_query, $per_page;
360 if ( empty( $posts ) )
361 $posts = $wp_query->posts;
363 add_filter( 'the_title', 'esc_html' );
365 if ( $this->hierarchical_display ) {
366 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
368 $this->_display_rows( $posts, $level );
372 function _display_rows( $posts, $level = 0 ) {
375 // Create array of post IDs.
378 foreach ( $posts as $a_post )
379 $post_ids[] = $a_post->ID;
381 $this->comment_pending_count = get_pending_comments_num( $post_ids );
383 foreach ( $posts as $post )
384 $this->single_row( $post, $level );
387 function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
393 $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
400 * Arrange pages into two parts: top level pages and children_pages
401 * children_pages is two dimensional array, eg.
402 * children_pages[10][] contains all sub-pages whose parent is 10.
403 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
404 * If searching, ignore hierarchy and treat everything as top level
406 if ( empty( $_REQUEST['s'] ) ) {
408 $top_level_pages = array();
409 $children_pages = array();
411 foreach ( $pages as $page ) {
413 // catch and repair bad pages
414 if ( $page->post_parent == $page->ID ) {
415 $page->post_parent = 0;
416 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
417 clean_post_cache( $page );
420 if ( 0 == $page->post_parent )
421 $top_level_pages[] = $page;
423 $children_pages[ $page->post_parent ][] = $page;
426 $pages = &$top_level_pages;
430 $start = ( $pagenum - 1 ) * $per_page;
431 $end = $start + $per_page;
433 foreach ( $pages as $page ) {
434 if ( $count >= $end )
437 if ( $count >= $start ) {
439 $this->single_row( $page, $level );
444 if ( isset( $children_pages ) )
445 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
448 // if it is the last pagenum and there are orphaned pages, display them with paging as well
449 if ( isset( $children_pages ) && $count < $end ){
450 foreach ( $children_pages as $orphans ){
451 foreach ( $orphans as $op ) {
452 if ( $count >= $end )
455 if ( $count >= $start ) {
457 $this->single_row( $op, 0 );
467 * Given a top level page ID, display the nested hierarchy of sub-pages
468 * together with paging support
470 * @since 3.1.0 (Standalone function exists since 2.6.0)
472 * @param array $children_pages
476 * @param int $pagenum
477 * @param int $per_page
479 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
481 if ( ! isset( $children_pages[$parent] ) )
484 $start = ( $pagenum - 1 ) * $per_page;
485 $end = $start + $per_page;
487 foreach ( $children_pages[$parent] as $page ) {
489 if ( $count >= $end )
492 // If the page starts in a subtree, print the parents.
493 if ( $count == $start && $page->post_parent > 0 ) {
494 $my_parents = array();
495 $my_parent = $page->post_parent;
496 while ( $my_parent ) {
497 $my_parent = get_post( $my_parent );
498 $my_parents[] = $my_parent;
499 if ( !$my_parent->post_parent )
501 $my_parent = $my_parent->post_parent;
503 $num_parents = count( $my_parents );
504 while ( $my_parent = array_pop( $my_parents ) ) {
506 $this->single_row( $my_parent, $level - $num_parents );
511 if ( $count >= $start ) {
513 $this->single_row( $page, $level );
518 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
521 unset( $children_pages[$parent] ); //required in order to keep track of orphans
524 function single_row( $post, $level = 0 ) {
528 $global_post = get_post();
529 $GLOBALS['post'] = $post;
530 setup_postdata( $post );
532 $edit_link = get_edit_post_link( $post->ID );
533 $title = _draft_or_post_title();
534 $post_type_object = get_post_type_object( $post->post_type );
535 $can_edit_post = current_user_can( 'edit_post', $post->ID );
537 $alternate = 'alternate' == $alternate ? '' : 'alternate';
538 $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
540 $lock_holder = wp_check_post_lock( $post->ID );
541 if ( $lock_holder ) {
542 $classes .= ' wp-locked';
543 $lock_holder = get_userdata( $lock_holder );
546 if ( $post->post_parent ) {
547 $count = count( get_post_ancestors( $post->ID ) );
548 $classes .= ' level-'. $count;
550 $classes .= ' level-0';
553 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
556 list( $columns, $hidden ) = $this->get_column_info();
558 foreach ( $columns as $column_name => $column_display_name ) {
559 $class = "class=\"$column_name column-$column_name\"";
562 if ( in_array( $column_name, $hidden ) )
563 $style = ' style="display:none;"';
565 $attributes = "$class$style";
567 switch ( $column_name ) {
571 <th scope="row" class="check-column">
573 if ( $can_edit_post ) {
576 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
577 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
578 <div class="locked-indicator"></div>
587 $attributes = 'class="post-title page-title column-title"' . $style;
588 if ( $this->hierarchical_display ) {
589 if ( 0 == $level && (int) $post->post_parent > 0 ) {
590 //sent level 0 by accident, by default, or because we don't know the actual level
591 $find_main_page = (int) $post->post_parent;
592 while ( $find_main_page > 0 ) {
593 $parent = get_post( $find_main_page );
595 if ( is_null( $parent ) )
599 $find_main_page = (int) $parent->post_parent;
601 if ( !isset( $parent_name ) ) {
602 /** This filter is documented in wp-includes/post-template.php */
603 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
609 $pad = str_repeat( '— ', $level );
610 echo "<td $attributes><strong>";
612 if ( $format = get_post_format( $post->ID ) ) {
613 $label = get_post_format_string( $format );
615 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> ";
618 if ( $can_edit_post && $post->post_status != 'trash' ) {
619 echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
623 _post_states( $post );
625 if ( isset( $parent_name ) )
626 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
630 if ( $can_edit_post && $post->post_status != 'trash' ) {
631 if ( $lock_holder ) {
632 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
633 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
635 $locked_avatar = $locked_text = '';
638 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
641 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
645 if ( $can_edit_post && 'trash' != $post->post_status ) {
646 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
647 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
649 if ( current_user_can( 'delete_post', $post->ID ) ) {
650 if ( 'trash' == $post->post_status )
651 $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>";
652 elseif ( EMPTY_TRASH_DAYS )
653 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
654 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
655 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
657 if ( $post_type_object->public ) {
658 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
659 if ( $can_edit_post ) {
661 /** This filter is documented in wp-admin/includes/meta-boxes.php */
662 $actions['view'] = '<a href="' . esc_url( apply_filters( 'preview_post_link', set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
664 } elseif ( 'trash' != $post->post_status ) {
665 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
669 if ( is_post_type_hierarchical( $post->post_type ) ) {
672 * Filter the array of row action links on the Pages list table.
674 * The filter is evaluated only for hierarchical post types.
678 * @param array $actions An array of row action links. Defaults are
679 * 'Edit', 'Quick Edit', 'Restore, 'Trash',
680 * 'Delete Permanently', 'Preview', and 'View'.
681 * @param WP_Post $post The post object.
683 $actions = apply_filters( 'page_row_actions', $actions, $post );
687 * Filter the array of row action links on the Posts list table.
689 * The filter is evaluated only for non-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( 'post_row_actions', $actions, $post );
701 echo $this->row_actions( $actions );
703 get_inline_data( $post );
708 if ( '0000-00-00 00:00:00' == $post->post_date ) {
709 $t_time = $h_time = __( 'Unpublished' );
712 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
713 $m_time = $post->post_date;
714 $time = get_post_time( 'G', true, $post );
716 $time_diff = time() - $time;
718 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
719 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
721 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
724 echo '<td ' . $attributes . '>';
725 if ( 'excerpt' == $mode ) {
728 * Filter the published time of the post.
730 * If $mode equals 'excerpt', the published time and date are both displayed.
731 * If $mode equals 'list' (default), the publish date is displayed, with the
732 * time and date together available as an abbreviation definition.
736 * @param array $t_time The published time.
737 * @param WP_Post $post Post object.
738 * @param string $column_name The column name.
739 * @param string $mode The list display mode ('excerpt' or 'list').
741 echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
744 /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
745 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
748 if ( 'publish' == $post->post_status ) {
750 } elseif ( 'future' == $post->post_status ) {
751 if ( $time_diff > 0 )
752 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
756 _e( 'Last Modified' );
763 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
765 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
767 $this->comments_bubble( $post->ID, $pending_comments );
775 <td <?php echo $attributes ?>><?php
776 printf( '<a href="%s">%s</a>',
777 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
785 if ( 'categories' == $column_name )
786 $taxonomy = 'category';
787 elseif ( 'tags' == $column_name )
788 $taxonomy = 'post_tag';
789 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
790 $taxonomy = substr( $column_name, 9 );
795 $taxonomy_object = get_taxonomy( $taxonomy );
796 echo '<td ' . $attributes . '>';
797 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
799 foreach ( $terms as $t ) {
800 $posts_in_term_qv = array();
801 if ( 'post' != $post->post_type )
802 $posts_in_term_qv['post_type'] = $post->post_type;
803 if ( $taxonomy_object->query_var ) {
804 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
806 $posts_in_term_qv['taxonomy'] = $taxonomy;
807 $posts_in_term_qv['term'] = $t->slug;
810 $out[] = sprintf( '<a href="%s">%s</a>',
811 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
812 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
815 /* translators: used between list items, there is a space after the comma */
816 echo join( __( ', ' ), $out );
824 <td <?php echo $attributes ?>><?php
825 if ( is_post_type_hierarchical( $post->post_type ) ) {
828 * Fires in each custom column on the Posts list table.
830 * This hook only fires if the current post type is hierarchical,
835 * @param string $column_name The name of the column to display.
836 * @param int $post_id The current post ID.
838 do_action( 'manage_pages_custom_column', $column_name, $post->ID );
842 * Fires in each custom column in the Posts list table.
844 * This hook only fires if the current post type is non-hierarchical,
849 * @param string $column_name The name of the column to display.
850 * @param int $post_id The current post ID.
852 do_action( 'manage_posts_custom_column', $column_name, $post->ID );
856 * Fires for each custom column of a specific post type in the Posts list table.
858 * The dynamic portion of the hook name, $post->post_type, refers to the post type.
862 * @param string $column_name The name of the column to display.
863 * @param int $post_id The current post ID.
865 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
874 $GLOBALS['post'] = $global_post;
878 * Outputs the hidden row displayed when inline editing
882 function inline_edit() {
885 $screen = $this->screen;
887 $post = get_default_post_to_edit( $screen->post_type );
888 $post_type_object = get_post_type_object( $screen->post_type );
890 $taxonomy_names = get_object_taxonomies( $screen->post_type );
891 $hierarchical_taxonomies = array();
892 $flat_taxonomies = array();
893 foreach ( $taxonomy_names as $taxonomy_name ) {
894 $taxonomy = get_taxonomy( $taxonomy_name );
896 if ( !$taxonomy->show_ui )
899 if ( $taxonomy->hierarchical )
900 $hierarchical_taxonomies[] = $taxonomy;
902 $flat_taxonomies[] = $taxonomy;
905 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
906 $can_publish = current_user_can( $post_type_object->cap->publish_posts );
907 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
911 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
913 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
915 while ( $bulk < 2 ) { ?>
917 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
918 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}";
919 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
921 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
922 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
925 if ( post_type_supports( $screen->post_type, 'title' ) ) :
927 <div id="bulk-title-div">
928 <div id="bulk-titles"></div>
931 <?php else : // $bulk ?>
934 <span class="title"><?php _e( 'Title' ); ?></span>
935 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
939 <span class="title"><?php _e( 'Slug' ); ?></span>
940 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
943 <?php endif; // $bulk
944 endif; // post_type_supports title ?>
946 <?php if ( !$bulk ) : ?>
947 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
948 <div class="inline-edit-date">
949 <?php touch_time( 1, 1, 0, 1 ); ?>
952 <?php endif; // $bulk
954 if ( post_type_supports( $screen->post_type, 'author' ) ) :
955 $authors_dropdown = '';
957 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
959 'hide_if_only_one_author' => false,
961 'name' => 'post_author',
967 $users_opt['show_option_none'] = __( '— No Change —' );
969 if ( $authors = wp_dropdown_users( $users_opt ) ) :
970 $authors_dropdown = '<label class="inline-edit-author">';
971 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
972 $authors_dropdown .= $authors;
973 $authors_dropdown .= '</label>';
978 <?php if ( !$bulk ) echo $authors_dropdown;
979 endif; // post_type_supports author
981 if ( !$bulk && $can_publish ) :
984 <div class="inline-edit-group">
985 <label class="alignleft">
986 <span class="title"><?php _e( 'Password' ); ?></span>
987 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
990 <em style="margin:5px 10px 0 0" class="alignleft">
992 /* translators: Between password field and private checkbox on post quick edit interface */
993 echo __( '–OR–' );
996 <label class="alignleft inline-edit-private">
997 <input type="checkbox" name="keep_private" value="private" />
998 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
1006 <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
1008 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1010 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
1012 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1013 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
1014 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
1015 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
1018 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
1022 <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
1024 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1027 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1028 echo $authors_dropdown;
1030 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1032 if ( $post_type_object->hierarchical ) :
1035 <span class="title"><?php _e( 'Parent' ); ?></span>
1037 $dropdown_args = array(
1038 'post_type' => $post_type_object->name,
1039 'selected' => $post->post_parent,
1040 'name' => 'post_parent',
1041 'show_option_none' => __( 'Main Page (no parent)' ),
1042 'option_none_value' => 0,
1043 'sort_column' => 'menu_order, post_title',
1047 $dropdown_args['show_option_no_change'] = __( '— No Change —' );
1050 * Filter the arguments used to generate the Quick Edit page-parent drop-down.
1054 * @see wp_dropdown_pages()
1056 * @param array $dropdown_args An array of arguments.
1058 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
1060 wp_dropdown_pages( $dropdown_args );
1065 endif; // hierarchical
1070 <span class="title"><?php _e( 'Order' ); ?></span>
1071 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1074 <?php endif; // !$bulk
1076 if ( 'page' == $screen->post_type ) :
1080 <span class="title"><?php _e( 'Template' ); ?></span>
1081 <select name="page_template">
1082 <?php if ( $bulk ) : ?>
1083 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1084 <?php endif; // $bulk ?>
1085 <option value="default"><?php _e( 'Default Template' ); ?></option>
1086 <?php page_template_dropdown() ?>
1091 endif; // page post_type
1092 endif; // page-attributes
1095 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
1097 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
1098 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
1099 <label class="inline-edit-tags">
1100 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1101 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
1105 <?php endforeach; //$flat_taxonomies as $taxonomy ?>
1107 <?php endif; // count( $flat_taxonomies ) && !$bulk ?>
1109 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
1112 <div class="inline-edit-group">
1113 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1114 <label class="alignleft">
1115 <span class="title"><?php _e( 'Comments' ); ?></span>
1116 <select name="comment_status">
1117 <option value=""><?php _e( '— No Change —' ); ?></option>
1118 <option value="open"><?php _e( 'Allow' ); ?></option>
1119 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1122 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1123 <label class="alignright">
1124 <span class="title"><?php _e( 'Pings' ); ?></span>
1125 <select name="ping_status">
1126 <option value=""><?php _e( '— No Change —' ); ?></option>
1127 <option value="open"><?php _e( 'Allow' ); ?></option>
1128 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1134 <?php else : // $bulk ?>
1136 <div class="inline-edit-group">
1137 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1138 <label class="alignleft">
1139 <input type="checkbox" name="comment_status" value="open" />
1140 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1142 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1143 <label class="alignleft">
1144 <input type="checkbox" name="ping_status" value="open" />
1145 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1150 <?php endif; // $bulk
1151 endif; // post_type_supports comments or pings ?>
1153 <div class="inline-edit-group">
1154 <label class="inline-edit-status alignleft">
1155 <span class="title"><?php _e( 'Status' ); ?></span>
1156 <select name="_status">
1157 <?php if ( $bulk ) : ?>
1158 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1159 <?php endif; // $bulk ?>
1160 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1161 <option value="publish"><?php _e( 'Published' ); ?></option>
1162 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1163 <?php if ( $bulk ) : ?>
1164 <option value="private"><?php _e( 'Private' ) ?></option>
1165 <?php endif; // $bulk ?>
1167 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1168 <option value="draft"><?php _e( 'Draft' ); ?></option>
1172 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1174 <?php if ( $bulk ) : ?>
1176 <label class="alignright">
1177 <span class="title"><?php _e( 'Sticky' ); ?></span>
1178 <select name="sticky">
1179 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1180 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1181 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1185 <?php else : // $bulk ?>
1187 <label class="alignleft">
1188 <input type="checkbox" name="sticky" value="sticky" />
1189 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1192 <?php endif; // $bulk ?>
1194 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1200 if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1201 $post_formats = get_theme_support( 'post-formats' );
1204 <label class="alignleft" for="post_format">
1205 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1206 <select name="post_format">
1207 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1208 <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
1211 foreach ( $post_formats[0] as $format ) {
1213 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
1228 list( $columns ) = $this->get_column_info();
1230 foreach ( $columns as $column_name => $column_display_name ) {
1231 if ( isset( $core_columns[$column_name] ) )
1237 * Fires once for each column in Bulk Edit mode.
1241 * @param string $column_name Name of the column to edit.
1242 * @param WP_Post $post_type The post type slug.
1244 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
1248 * Fires once for each column in Quick Edit mode.
1252 * @param string $column_name Name of the column to edit.
1253 * @param WP_Post $post_type The post type slug.
1255 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type );
1260 <p class="submit inline-edit-save">
1261 <a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
1262 <?php if ( ! $bulk ) {
1263 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1265 <a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
1266 <span class="spinner"></span>
1268 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
1270 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1271 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1272 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1273 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1275 <span class="error" style="display:none"></span>
1276 <br class="clear" />
1283 </tbody></table></form>