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 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
61 SELECT COUNT( 1 ) FROM $wpdb->posts
62 WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' )
64 ", $post_type, get_current_user_id() ) );
66 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) )
67 $_GET['author'] = get_current_user_id();
70 if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
71 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
72 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) );
76 function ajax_user_can() {
77 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
80 function prepare_items() {
81 global $avail_post_stati, $wp_query, $per_page, $mode;
83 $avail_post_stati = wp_edit_posts_query();
85 $this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
87 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
89 $post_type = $this->screen->post_type;
90 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
91 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
93 if ( $this->hierarchical_display )
94 $total_pages = ceil( $total_items / $per_page );
96 $total_pages = $wp_query->max_num_pages;
98 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
100 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
102 $this->set_pagination_args( array(
103 'total_items' => $total_items,
104 'total_pages' => $total_pages,
105 'per_page' => $per_page
109 function has_items() {
113 function no_items() {
114 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
115 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
117 echo get_post_type_object( $this->screen->post_type )->labels->not_found;
120 function get_views() {
121 global $locked_post_status, $avail_post_stati;
123 $post_type = $this->screen->post_type;
125 if ( !empty($locked_post_status) )
128 $status_links = array();
129 $num_posts = wp_count_posts( $post_type, 'readable' );
133 $current_user_id = get_current_user_id();
135 if ( $this->user_posts_count ) {
136 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
137 $class = ' class="current"';
138 $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>';
139 $allposts = '&all_posts=1';
142 $total_posts = array_sum( (array) $num_posts );
144 // Subtract post types that are not included in the admin all list.
145 foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
146 $total_posts -= $num_posts->$state;
148 $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
149 $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>';
151 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
154 $status_name = $status->name;
156 if ( !in_array( $status_name, $avail_post_stati ) )
159 if ( empty( $num_posts->$status_name ) )
162 if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
163 $class = ' class="current"';
165 $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>';
168 if ( ! empty( $this->sticky_posts_count ) ) {
169 $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
171 $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>' );
173 // Sticky comes after Publish, or if not listed, after All.
174 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
175 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
178 return $status_links;
181 function get_bulk_actions() {
184 if ( $this->is_trash )
185 $actions['untrash'] = __( 'Restore' );
187 $actions['edit'] = __( 'Edit' );
189 if ( $this->is_trash || !EMPTY_TRASH_DAYS )
190 $actions['delete'] = __( 'Delete Permanently' );
192 $actions['trash'] = __( 'Move to Trash' );
197 function extra_tablenav( $which ) {
200 <div class="alignleft actions">
202 if ( 'top' == $which && !is_singular() ) {
204 $this->months_dropdown( $this->screen->post_type );
206 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
207 $dropdown_options = array(
208 'show_option_all' => __( 'View all categories' ),
215 wp_dropdown_categories( $dropdown_options );
217 do_action( 'restrict_manage_posts' );
218 submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) );
221 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
222 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
229 function current_action() {
230 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
233 return parent::current_action();
236 function pagination( $which ) {
239 parent::pagination( $which );
241 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
242 $this->view_switcher( $mode );
245 function get_table_classes() {
246 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
249 function get_columns() {
250 $post_type = $this->screen->post_type;
252 $posts_columns = array();
254 $posts_columns['cb'] = '<input type="checkbox" />';
256 /* translators: manage posts column name */
257 $posts_columns['title'] = _x( 'Title', 'column name' );
259 if ( post_type_supports( $post_type, 'author' ) )
260 $posts_columns['author'] = __( 'Author' );
262 $taxonomies = array();
264 $taxonomies = get_object_taxonomies( $post_type, 'objects' );
265 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
267 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
268 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
270 foreach ( $taxonomies as $taxonomy ) {
271 if ( 'category' == $taxonomy )
272 $column_key = 'categories';
273 elseif ( 'post_tag' == $taxonomy )
274 $column_key = 'tags';
276 $column_key = 'taxonomy-' . $taxonomy;
278 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
281 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
282 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
283 $posts_columns['comments'] = '<span class="vers"><div title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></div></span>';
285 $posts_columns['date'] = __( 'Date' );
287 if ( 'page' == $post_type )
288 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
290 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
291 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
293 return $posts_columns;
296 function get_sortable_columns() {
299 'parent' => 'parent',
300 'comments' => 'comment_count',
301 'date' => array( 'date', true )
305 function display_rows( $posts = array(), $level = 0 ) {
306 global $wp_query, $per_page;
308 if ( empty( $posts ) )
309 $posts = $wp_query->posts;
311 add_filter( 'the_title', 'esc_html' );
313 if ( $this->hierarchical_display ) {
314 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
316 $this->_display_rows( $posts, $level );
320 function _display_rows( $posts, $level = 0 ) {
323 // Create array of post IDs.
326 foreach ( $posts as $a_post )
327 $post_ids[] = $a_post->ID;
329 $this->comment_pending_count = get_pending_comments_num( $post_ids );
331 foreach ( $posts as $post )
332 $this->single_row( $post, $level );
335 function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
341 $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
348 * arrange pages into two parts: top level pages and children_pages
349 * children_pages is two dimensional array, eg.
350 * children_pages[10][] contains all sub-pages whose parent is 10.
351 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
352 * If searching, ignore hierarchy and treat everything as top level
354 if ( empty( $_REQUEST['s'] ) ) {
356 $top_level_pages = array();
357 $children_pages = array();
359 foreach ( $pages as $page ) {
361 // catch and repair bad pages
362 if ( $page->post_parent == $page->ID ) {
363 $page->post_parent = 0;
364 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
365 clean_post_cache( $page );
368 if ( 0 == $page->post_parent )
369 $top_level_pages[] = $page;
371 $children_pages[ $page->post_parent ][] = $page;
374 $pages = &$top_level_pages;
378 $start = ( $pagenum - 1 ) * $per_page;
379 $end = $start + $per_page;
381 foreach ( $pages as $page ) {
382 if ( $count >= $end )
385 if ( $count >= $start ) {
387 $this->single_row( $page, $level );
392 if ( isset( $children_pages ) )
393 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
396 // if it is the last pagenum and there are orphaned pages, display them with paging as well
397 if ( isset( $children_pages ) && $count < $end ){
398 foreach ( $children_pages as $orphans ){
399 foreach ( $orphans as $op ) {
400 if ( $count >= $end )
403 if ( $count >= $start ) {
405 $this->single_row( $op, 0 );
415 * Given a top level page ID, display the nested hierarchy of sub-pages
416 * together with paging support
418 * @since 3.1.0 (Standalone function exists since 2.6.0)
420 * @param unknown_type $children_pages
421 * @param unknown_type $count
422 * @param unknown_type $parent
423 * @param unknown_type $level
424 * @param unknown_type $pagenum
425 * @param unknown_type $per_page
427 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
429 if ( ! isset( $children_pages[$parent] ) )
432 $start = ( $pagenum - 1 ) * $per_page;
433 $end = $start + $per_page;
435 foreach ( $children_pages[$parent] as $page ) {
437 if ( $count >= $end )
440 // If the page starts in a subtree, print the parents.
441 if ( $count == $start && $page->post_parent > 0 ) {
442 $my_parents = array();
443 $my_parent = $page->post_parent;
444 while ( $my_parent ) {
445 $my_parent = get_post( $my_parent );
446 $my_parents[] = $my_parent;
447 if ( !$my_parent->post_parent )
449 $my_parent = $my_parent->post_parent;
451 $num_parents = count( $my_parents );
452 while ( $my_parent = array_pop( $my_parents ) ) {
454 $this->single_row( $my_parent, $level - $num_parents );
459 if ( $count >= $start ) {
461 $this->single_row( $page, $level );
466 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
469 unset( $children_pages[$parent] ); //required in order to keep track of orphans
472 function single_row( $post, $level = 0 ) {
476 $global_post = get_post();
477 $GLOBALS['post'] = $post;
478 setup_postdata( $post );
480 $edit_link = get_edit_post_link( $post->ID );
481 $title = _draft_or_post_title();
482 $post_type_object = get_post_type_object( $post->post_type );
483 $can_edit_post = current_user_can( 'edit_post', $post->ID );
485 $alternate = 'alternate' == $alternate ? '' : 'alternate';
486 $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
488 $lock_holder = wp_check_post_lock( $post->ID );
489 if ( $lock_holder ) {
490 $classes .= ' wp-locked';
491 $lock_holder = get_userdata( $lock_holder );
494 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
497 list( $columns, $hidden ) = $this->get_column_info();
499 foreach ( $columns as $column_name => $column_display_name ) {
500 $class = "class=\"$column_name column-$column_name\"";
503 if ( in_array( $column_name, $hidden ) )
504 $style = ' style="display:none;"';
506 $attributes = "$class$style";
508 switch ( $column_name ) {
512 <th scope="row" class="check-column">
514 if ( $can_edit_post ) {
517 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
518 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
519 <div class="locked-indicator"></div>
528 $attributes = 'class="post-title page-title column-title"' . $style;
529 if ( $this->hierarchical_display ) {
530 if ( 0 == $level && (int) $post->post_parent > 0 ) {
531 //sent level 0 by accident, by default, or because we don't know the actual level
532 $find_main_page = (int) $post->post_parent;
533 while ( $find_main_page > 0 ) {
534 $parent = get_post( $find_main_page );
536 if ( is_null( $parent ) )
540 $find_main_page = (int) $parent->post_parent;
542 if ( !isset( $parent_name ) )
543 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
548 $pad = str_repeat( '— ', $level );
549 echo "<td $attributes><strong>";
551 if ( $format = get_post_format( $post->ID ) ) {
552 $label = get_post_format_string( $format );
554 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> ";
557 if ( $can_edit_post && $post->post_status != 'trash' ) {
558 echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
562 _post_states( $post );
564 if ( isset( $parent_name ) )
565 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
569 if ( $can_edit_post && $post->post_status != 'trash' ) {
570 if ( $lock_holder ) {
571 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
572 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
574 $locked_avatar = $locked_text = '';
577 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
580 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
584 if ( $can_edit_post && 'trash' != $post->post_status ) {
585 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
586 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
588 if ( current_user_can( 'delete_post', $post->ID ) ) {
589 if ( 'trash' == $post->post_status )
590 $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>";
591 elseif ( EMPTY_TRASH_DAYS )
592 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
593 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
594 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
596 if ( $post_type_object->public ) {
597 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
598 if ( $can_edit_post )
599 $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>';
600 } elseif ( 'trash' != $post->post_status ) {
601 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
605 $actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post );
606 echo $this->row_actions( $actions );
608 get_inline_data( $post );
613 if ( '0000-00-00 00:00:00' == $post->post_date ) {
614 $t_time = $h_time = __( 'Unpublished' );
617 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
618 $m_time = $post->post_date;
619 $time = get_post_time( 'G', true, $post );
621 $time_diff = time() - $time;
623 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
624 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
626 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
629 echo '<td ' . $attributes . '>';
630 if ( 'excerpt' == $mode )
631 echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
633 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
635 if ( 'publish' == $post->post_status ) {
637 } elseif ( 'future' == $post->post_status ) {
638 if ( $time_diff > 0 )
639 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
643 _e( 'Last Modified' );
650 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
652 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
654 $this->comments_bubble( $post->ID, $pending_comments );
662 <td <?php echo $attributes ?>><?php
663 printf( '<a href="%s">%s</a>',
664 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
672 if ( 'categories' == $column_name )
673 $taxonomy = 'category';
674 elseif ( 'tags' == $column_name )
675 $taxonomy = 'post_tag';
676 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
677 $taxonomy = substr( $column_name, 9 );
682 $taxonomy_object = get_taxonomy( $taxonomy );
683 echo '<td ' . $attributes . '>';
684 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
686 foreach ( $terms as $t ) {
687 $posts_in_term_qv = array();
688 if ( 'post' != $post->post_type )
689 $posts_in_term_qv['post_type'] = $post->post_type;
690 if ( $taxonomy_object->query_var ) {
691 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
693 $posts_in_term_qv['taxonomy'] = $taxonomy;
694 $posts_in_term_qv['term'] = $t->slug;
697 $out[] = sprintf( '<a href="%s">%s</a>',
698 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
699 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
702 /* translators: used between list items, there is a space after the comma */
703 echo join( __( ', ' ), $out );
711 <td <?php echo $attributes ?>><?php
712 if ( is_post_type_hierarchical( $post->post_type ) )
713 do_action( 'manage_pages_custom_column', $column_name, $post->ID );
715 do_action( 'manage_posts_custom_column', $column_name, $post->ID );
716 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
725 $GLOBALS['post'] = $global_post;
729 * Outputs the hidden row displayed when inline editing
733 function inline_edit() {
736 $screen = $this->screen;
738 $post = get_default_post_to_edit( $screen->post_type );
739 $post_type_object = get_post_type_object( $screen->post_type );
741 $taxonomy_names = get_object_taxonomies( $screen->post_type );
742 $hierarchical_taxonomies = array();
743 $flat_taxonomies = array();
744 foreach ( $taxonomy_names as $taxonomy_name ) {
745 $taxonomy = get_taxonomy( $taxonomy_name );
747 if ( !$taxonomy->show_ui )
750 if ( $taxonomy->hierarchical )
751 $hierarchical_taxonomies[] = $taxonomy;
753 $flat_taxonomies[] = $taxonomy;
756 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
757 $can_publish = current_user_can( $post_type_object->cap->publish_posts );
758 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
762 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
764 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
766 while ( $bulk < 2 ) { ?>
768 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
769 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}";
770 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
772 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
773 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
776 if ( post_type_supports( $screen->post_type, 'title' ) ) :
778 <div id="bulk-title-div">
779 <div id="bulk-titles"></div>
782 <?php else : // $bulk ?>
785 <span class="title"><?php _e( 'Title' ); ?></span>
786 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
790 <span class="title"><?php _e( 'Slug' ); ?></span>
791 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
794 <?php endif; // $bulk
795 endif; // post_type_supports title ?>
797 <?php if ( !$bulk ) : ?>
798 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
799 <div class="inline-edit-date">
800 <?php touch_time( 1, 1, 0, 1 ); ?>
803 <?php endif; // $bulk
805 if ( post_type_supports( $screen->post_type, 'author' ) ) :
806 $authors_dropdown = '';
808 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
810 'hide_if_only_one_author' => false,
812 'name' => 'post_author',
818 $users_opt['show_option_none'] = __( '— No Change —' );
820 if ( $authors = wp_dropdown_users( $users_opt ) ) :
821 $authors_dropdown = '<label class="inline-edit-author">';
822 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
823 $authors_dropdown .= $authors;
824 $authors_dropdown .= '</label>';
829 <?php if ( !$bulk ) echo $authors_dropdown;
830 endif; // post_type_supports author
835 <div class="inline-edit-group">
836 <label class="alignleft">
837 <span class="title"><?php _e( 'Password' ); ?></span>
838 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
841 <em style="margin:5px 10px 0 0" class="alignleft">
843 /* translators: Between password field and private checkbox on post quick edit interface */
844 echo __( '–OR–' );
847 <label class="alignleft inline-edit-private">
848 <input type="checkbox" name="keep_private" value="private" />
849 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
857 <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
859 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
861 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
863 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
864 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
865 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
866 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
869 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
873 <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
875 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
878 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
879 echo $authors_dropdown;
881 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
883 if ( $post_type_object->hierarchical ) :
886 <span class="title"><?php _e( 'Parent' ); ?></span>
888 $dropdown_args = array(
889 'post_type' => $post_type_object->name,
890 'selected' => $post->post_parent,
891 'name' => 'post_parent',
892 'show_option_none' => __( 'Main Page (no parent)' ),
893 'option_none_value' => 0,
894 'sort_column' => 'menu_order, post_title',
898 $dropdown_args['show_option_no_change'] = __( '— No Change —' );
899 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
900 wp_dropdown_pages( $dropdown_args );
905 endif; // hierarchical
910 <span class="title"><?php _e( 'Order' ); ?></span>
911 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
914 <?php endif; // !$bulk
916 if ( 'page' == $screen->post_type ) :
920 <span class="title"><?php _e( 'Template' ); ?></span>
921 <select name="page_template">
922 <?php if ( $bulk ) : ?>
923 <option value="-1"><?php _e( '— No Change —' ); ?></option>
924 <?php endif; // $bulk ?>
925 <option value="default"><?php _e( 'Default Template' ); ?></option>
926 <?php page_template_dropdown() ?>
931 endif; // page post_type
932 endif; // page-attributes
935 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
937 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
938 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
939 <label class="inline-edit-tags">
940 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
941 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
945 <?php endforeach; //$flat_taxonomies as $taxonomy ?>
947 <?php endif; // count( $flat_taxonomies ) && !$bulk ?>
949 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
952 <div class="inline-edit-group">
953 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
954 <label class="alignleft">
955 <span class="title"><?php _e( 'Comments' ); ?></span>
956 <select name="comment_status">
957 <option value=""><?php _e( '— No Change —' ); ?></option>
958 <option value="open"><?php _e( 'Allow' ); ?></option>
959 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
962 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
963 <label class="alignright">
964 <span class="title"><?php _e( 'Pings' ); ?></span>
965 <select name="ping_status">
966 <option value=""><?php _e( '— No Change —' ); ?></option>
967 <option value="open"><?php _e( 'Allow' ); ?></option>
968 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
974 <?php else : // $bulk ?>
976 <div class="inline-edit-group">
977 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
978 <label class="alignleft">
979 <input type="checkbox" name="comment_status" value="open" />
980 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
982 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
983 <label class="alignleft">
984 <input type="checkbox" name="ping_status" value="open" />
985 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
990 <?php endif; // $bulk
991 endif; // post_type_supports comments or pings ?>
993 <div class="inline-edit-group">
994 <label class="inline-edit-status alignleft">
995 <span class="title"><?php _e( 'Status' ); ?></span>
996 <select name="_status">
997 <?php if ( $bulk ) : ?>
998 <option value="-1"><?php _e( '— No Change —' ); ?></option>
999 <?php endif; // $bulk ?>
1000 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1001 <option value="publish"><?php _e( 'Published' ); ?></option>
1002 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1003 <?php if ( $bulk ) : ?>
1004 <option value="private"><?php _e( 'Private' ) ?></option>
1005 <?php endif; // $bulk ?>
1007 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1008 <option value="draft"><?php _e( 'Draft' ); ?></option>
1012 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1014 <?php if ( $bulk ) : ?>
1016 <label class="alignright">
1017 <span class="title"><?php _e( 'Sticky' ); ?></span>
1018 <select name="sticky">
1019 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1020 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1021 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1025 <?php else : // $bulk ?>
1027 <label class="alignleft">
1028 <input type="checkbox" name="sticky" value="sticky" />
1029 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1032 <?php endif; // $bulk ?>
1034 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1040 list( $columns ) = $this->get_column_info();
1042 foreach ( $columns as $column_name => $column_display_name ) {
1043 if ( isset( $core_columns[$column_name] ) )
1045 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
1048 <p class="submit inline-edit-save">
1049 <a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
1050 <?php if ( ! $bulk ) {
1051 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1053 <a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
1054 <span class="spinner"></span>
1056 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
1058 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1059 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1060 <span class="error" style="display:none"></span>
1061 <br class="clear" />
1068 </tbody></table></form>