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' );
92 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
94 if ( $this->hierarchical_display )
95 $total_pages = ceil( $total_items / $per_page );
97 $total_pages = $wp_query->max_num_pages;
99 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
101 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
103 $this->set_pagination_args( array(
104 'total_items' => $total_items,
105 'total_pages' => $total_pages,
106 'per_page' => $per_page
110 function has_items() {
114 function no_items() {
115 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
116 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
118 echo get_post_type_object( $this->screen->post_type )->labels->not_found;
121 function get_views() {
122 global $locked_post_status, $avail_post_stati;
124 $post_type = $this->screen->post_type;
126 if ( !empty($locked_post_status) )
129 $status_links = array();
130 $num_posts = wp_count_posts( $post_type, 'readable' );
134 $current_user_id = get_current_user_id();
136 if ( $this->user_posts_count ) {
137 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
138 $class = ' class="current"';
139 $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>';
140 $allposts = '&all_posts=1';
143 $total_posts = array_sum( (array) $num_posts );
145 // Subtract post types that are not included in the admin all list.
146 foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
147 $total_posts -= $num_posts->$state;
149 $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
150 $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>';
152 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
155 $status_name = $status->name;
157 if ( !in_array( $status_name, $avail_post_stati ) )
160 if ( empty( $num_posts->$status_name ) )
163 if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
164 $class = ' class="current"';
166 $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>';
169 if ( ! empty( $this->sticky_posts_count ) ) {
170 $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
172 $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>' );
174 // Sticky comes after Publish, or if not listed, after All.
175 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
176 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
179 return $status_links;
182 function get_bulk_actions() {
185 if ( $this->is_trash )
186 $actions['untrash'] = __( 'Restore' );
188 $actions['edit'] = __( 'Edit' );
190 if ( $this->is_trash || !EMPTY_TRASH_DAYS )
191 $actions['delete'] = __( 'Delete Permanently' );
193 $actions['trash'] = __( 'Move to Trash' );
198 function extra_tablenav( $which ) {
201 <div class="alignleft actions">
203 if ( 'top' == $which && !is_singular() ) {
205 $this->months_dropdown( $this->screen->post_type );
207 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
208 $dropdown_options = array(
209 'show_option_all' => __( 'View all categories' ),
216 wp_dropdown_categories( $dropdown_options );
218 do_action( 'restrict_manage_posts' );
219 submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) );
222 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
223 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
230 function current_action() {
231 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
234 return parent::current_action();
237 function pagination( $which ) {
240 parent::pagination( $which );
242 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
243 $this->view_switcher( $mode );
246 function get_table_classes() {
247 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
250 function get_columns() {
251 $post_type = $this->screen->post_type;
253 $posts_columns = array();
255 $posts_columns['cb'] = '<input type="checkbox" />';
257 /* translators: manage posts column name */
258 $posts_columns['title'] = _x( 'Title', 'column name' );
260 if ( post_type_supports( $post_type, 'author' ) )
261 $posts_columns['author'] = __( 'Author' );
263 $taxonomies = array();
265 $taxonomies = get_object_taxonomies( $post_type, 'objects' );
266 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
268 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
269 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
271 foreach ( $taxonomies as $taxonomy ) {
272 if ( 'category' == $taxonomy )
273 $column_key = 'categories';
274 elseif ( 'post_tag' == $taxonomy )
275 $column_key = 'tags';
277 $column_key = 'taxonomy-' . $taxonomy;
279 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
282 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
283 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
284 $posts_columns['comments'] = '<span class="vers"><div title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></div></span>';
286 $posts_columns['date'] = __( 'Date' );
288 if ( 'page' == $post_type )
289 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
291 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
292 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
294 return $posts_columns;
297 function get_sortable_columns() {
300 'parent' => 'parent',
301 'comments' => 'comment_count',
302 'date' => array( 'date', true )
306 function display_rows( $posts = array(), $level = 0 ) {
307 global $wp_query, $per_page;
309 if ( empty( $posts ) )
310 $posts = $wp_query->posts;
312 add_filter( 'the_title', 'esc_html' );
314 if ( $this->hierarchical_display ) {
315 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
317 $this->_display_rows( $posts, $level );
321 function _display_rows( $posts, $level = 0 ) {
324 // Create array of post IDs.
327 foreach ( $posts as $a_post )
328 $post_ids[] = $a_post->ID;
330 $this->comment_pending_count = get_pending_comments_num( $post_ids );
332 foreach ( $posts as $post )
333 $this->single_row( $post, $level );
336 function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
342 $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
349 * arrange pages into two parts: top level pages and children_pages
350 * children_pages is two dimensional array, eg.
351 * children_pages[10][] contains all sub-pages whose parent is 10.
352 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
353 * If searching, ignore hierarchy and treat everything as top level
355 if ( empty( $_REQUEST['s'] ) ) {
357 $top_level_pages = array();
358 $children_pages = array();
360 foreach ( $pages as $page ) {
362 // catch and repair bad pages
363 if ( $page->post_parent == $page->ID ) {
364 $page->post_parent = 0;
365 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
366 clean_post_cache( $page );
369 if ( 0 == $page->post_parent )
370 $top_level_pages[] = $page;
372 $children_pages[ $page->post_parent ][] = $page;
375 $pages = &$top_level_pages;
379 $start = ( $pagenum - 1 ) * $per_page;
380 $end = $start + $per_page;
382 foreach ( $pages as $page ) {
383 if ( $count >= $end )
386 if ( $count >= $start ) {
388 $this->single_row( $page, $level );
393 if ( isset( $children_pages ) )
394 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
397 // if it is the last pagenum and there are orphaned pages, display them with paging as well
398 if ( isset( $children_pages ) && $count < $end ){
399 foreach ( $children_pages as $orphans ){
400 foreach ( $orphans as $op ) {
401 if ( $count >= $end )
404 if ( $count >= $start ) {
406 $this->single_row( $op, 0 );
416 * Given a top level page ID, display the nested hierarchy of sub-pages
417 * together with paging support
419 * @since 3.1.0 (Standalone function exists since 2.6.0)
421 * @param array $children_pages
425 * @param int $pagenum
426 * @param int $per_page
428 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
430 if ( ! isset( $children_pages[$parent] ) )
433 $start = ( $pagenum - 1 ) * $per_page;
434 $end = $start + $per_page;
436 foreach ( $children_pages[$parent] as $page ) {
438 if ( $count >= $end )
441 // If the page starts in a subtree, print the parents.
442 if ( $count == $start && $page->post_parent > 0 ) {
443 $my_parents = array();
444 $my_parent = $page->post_parent;
445 while ( $my_parent ) {
446 $my_parent = get_post( $my_parent );
447 $my_parents[] = $my_parent;
448 if ( !$my_parent->post_parent )
450 $my_parent = $my_parent->post_parent;
452 $num_parents = count( $my_parents );
453 while ( $my_parent = array_pop( $my_parents ) ) {
455 $this->single_row( $my_parent, $level - $num_parents );
460 if ( $count >= $start ) {
462 $this->single_row( $page, $level );
467 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
470 unset( $children_pages[$parent] ); //required in order to keep track of orphans
473 function single_row( $post, $level = 0 ) {
477 $global_post = get_post();
478 $GLOBALS['post'] = $post;
479 setup_postdata( $post );
481 $edit_link = get_edit_post_link( $post->ID );
482 $title = _draft_or_post_title();
483 $post_type_object = get_post_type_object( $post->post_type );
484 $can_edit_post = current_user_can( 'edit_post', $post->ID );
486 $alternate = 'alternate' == $alternate ? '' : 'alternate';
487 $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
489 $lock_holder = wp_check_post_lock( $post->ID );
490 if ( $lock_holder ) {
491 $classes .= ' wp-locked';
492 $lock_holder = get_userdata( $lock_holder );
495 if ( $post->post_parent ) {
496 $count = count( get_post_ancestors( $post->ID ) );
497 $classes .= ' level-'. $count;
499 $classes .= ' level-0';
502 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
505 list( $columns, $hidden ) = $this->get_column_info();
507 foreach ( $columns as $column_name => $column_display_name ) {
508 $class = "class=\"$column_name column-$column_name\"";
511 if ( in_array( $column_name, $hidden ) )
512 $style = ' style="display:none;"';
514 $attributes = "$class$style";
516 switch ( $column_name ) {
520 <th scope="row" class="check-column">
522 if ( $can_edit_post ) {
525 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
526 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
527 <div class="locked-indicator"></div>
536 $attributes = 'class="post-title page-title column-title"' . $style;
537 if ( $this->hierarchical_display ) {
538 if ( 0 == $level && (int) $post->post_parent > 0 ) {
539 //sent level 0 by accident, by default, or because we don't know the actual level
540 $find_main_page = (int) $post->post_parent;
541 while ( $find_main_page > 0 ) {
542 $parent = get_post( $find_main_page );
544 if ( is_null( $parent ) )
548 $find_main_page = (int) $parent->post_parent;
550 if ( !isset( $parent_name ) ) {
551 /** This filter is documented in wp-includes/post-template.php */
552 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
558 $pad = str_repeat( '— ', $level );
559 echo "<td $attributes><strong>";
561 if ( $format = get_post_format( $post->ID ) ) {
562 $label = get_post_format_string( $format );
564 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> ";
567 if ( $can_edit_post && $post->post_status != 'trash' ) {
568 echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
572 _post_states( $post );
574 if ( isset( $parent_name ) )
575 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
579 if ( $can_edit_post && $post->post_status != 'trash' ) {
580 if ( $lock_holder ) {
581 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
582 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
584 $locked_avatar = $locked_text = '';
587 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
590 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
594 if ( $can_edit_post && 'trash' != $post->post_status ) {
595 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
596 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
598 if ( current_user_can( 'delete_post', $post->ID ) ) {
599 if ( 'trash' == $post->post_status )
600 $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>";
601 elseif ( EMPTY_TRASH_DAYS )
602 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
603 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
604 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
606 if ( $post_type_object->public ) {
607 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
608 if ( $can_edit_post )
609 $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>';
610 } elseif ( 'trash' != $post->post_status ) {
611 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
615 $actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post );
616 echo $this->row_actions( $actions );
618 get_inline_data( $post );
623 if ( '0000-00-00 00:00:00' == $post->post_date ) {
624 $t_time = $h_time = __( 'Unpublished' );
627 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
628 $m_time = $post->post_date;
629 $time = get_post_time( 'G', true, $post );
631 $time_diff = time() - $time;
633 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
634 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
636 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
639 echo '<td ' . $attributes . '>';
640 if ( 'excerpt' == $mode )
641 echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
643 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
645 if ( 'publish' == $post->post_status ) {
647 } elseif ( 'future' == $post->post_status ) {
648 if ( $time_diff > 0 )
649 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
653 _e( 'Last Modified' );
660 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
662 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
664 $this->comments_bubble( $post->ID, $pending_comments );
672 <td <?php echo $attributes ?>><?php
673 printf( '<a href="%s">%s</a>',
674 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
682 if ( 'categories' == $column_name )
683 $taxonomy = 'category';
684 elseif ( 'tags' == $column_name )
685 $taxonomy = 'post_tag';
686 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
687 $taxonomy = substr( $column_name, 9 );
692 $taxonomy_object = get_taxonomy( $taxonomy );
693 echo '<td ' . $attributes . '>';
694 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
696 foreach ( $terms as $t ) {
697 $posts_in_term_qv = array();
698 if ( 'post' != $post->post_type )
699 $posts_in_term_qv['post_type'] = $post->post_type;
700 if ( $taxonomy_object->query_var ) {
701 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
703 $posts_in_term_qv['taxonomy'] = $taxonomy;
704 $posts_in_term_qv['term'] = $t->slug;
707 $out[] = sprintf( '<a href="%s">%s</a>',
708 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
709 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
712 /* translators: used between list items, there is a space after the comma */
713 echo join( __( ', ' ), $out );
721 <td <?php echo $attributes ?>><?php
722 if ( is_post_type_hierarchical( $post->post_type ) )
723 do_action( 'manage_pages_custom_column', $column_name, $post->ID );
725 do_action( 'manage_posts_custom_column', $column_name, $post->ID );
726 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
735 $GLOBALS['post'] = $global_post;
739 * Outputs the hidden row displayed when inline editing
743 function inline_edit() {
746 $screen = $this->screen;
748 $post = get_default_post_to_edit( $screen->post_type );
749 $post_type_object = get_post_type_object( $screen->post_type );
751 $taxonomy_names = get_object_taxonomies( $screen->post_type );
752 $hierarchical_taxonomies = array();
753 $flat_taxonomies = array();
754 foreach ( $taxonomy_names as $taxonomy_name ) {
755 $taxonomy = get_taxonomy( $taxonomy_name );
757 if ( !$taxonomy->show_ui )
760 if ( $taxonomy->hierarchical )
761 $hierarchical_taxonomies[] = $taxonomy;
763 $flat_taxonomies[] = $taxonomy;
766 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
767 $can_publish = current_user_can( $post_type_object->cap->publish_posts );
768 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
772 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
774 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
776 while ( $bulk < 2 ) { ?>
778 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
779 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}";
780 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
782 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
783 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
786 if ( post_type_supports( $screen->post_type, 'title' ) ) :
788 <div id="bulk-title-div">
789 <div id="bulk-titles"></div>
792 <?php else : // $bulk ?>
795 <span class="title"><?php _e( 'Title' ); ?></span>
796 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
800 <span class="title"><?php _e( 'Slug' ); ?></span>
801 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
804 <?php endif; // $bulk
805 endif; // post_type_supports title ?>
807 <?php if ( !$bulk ) : ?>
808 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
809 <div class="inline-edit-date">
810 <?php touch_time( 1, 1, 0, 1 ); ?>
813 <?php endif; // $bulk
815 if ( post_type_supports( $screen->post_type, 'author' ) ) :
816 $authors_dropdown = '';
818 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
820 'hide_if_only_one_author' => false,
822 'name' => 'post_author',
828 $users_opt['show_option_none'] = __( '— No Change —' );
830 if ( $authors = wp_dropdown_users( $users_opt ) ) :
831 $authors_dropdown = '<label class="inline-edit-author">';
832 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
833 $authors_dropdown .= $authors;
834 $authors_dropdown .= '</label>';
839 <?php if ( !$bulk ) echo $authors_dropdown;
840 endif; // post_type_supports author
845 <div class="inline-edit-group">
846 <label class="alignleft">
847 <span class="title"><?php _e( 'Password' ); ?></span>
848 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
851 <em style="margin:5px 10px 0 0" class="alignleft">
853 /* translators: Between password field and private checkbox on post quick edit interface */
854 echo __( '–OR–' );
857 <label class="alignleft inline-edit-private">
858 <input type="checkbox" name="keep_private" value="private" />
859 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
867 <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
869 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
871 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
873 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
874 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
875 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
876 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
879 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
883 <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
885 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
888 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
889 echo $authors_dropdown;
891 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
893 if ( $post_type_object->hierarchical ) :
896 <span class="title"><?php _e( 'Parent' ); ?></span>
898 $dropdown_args = array(
899 'post_type' => $post_type_object->name,
900 'selected' => $post->post_parent,
901 'name' => 'post_parent',
902 'show_option_none' => __( 'Main Page (no parent)' ),
903 'option_none_value' => 0,
904 'sort_column' => 'menu_order, post_title',
908 $dropdown_args['show_option_no_change'] = __( '— No Change —' );
909 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
910 wp_dropdown_pages( $dropdown_args );
915 endif; // hierarchical
920 <span class="title"><?php _e( 'Order' ); ?></span>
921 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
924 <?php endif; // !$bulk
926 if ( 'page' == $screen->post_type ) :
930 <span class="title"><?php _e( 'Template' ); ?></span>
931 <select name="page_template">
932 <?php if ( $bulk ) : ?>
933 <option value="-1"><?php _e( '— No Change —' ); ?></option>
934 <?php endif; // $bulk ?>
935 <option value="default"><?php _e( 'Default Template' ); ?></option>
936 <?php page_template_dropdown() ?>
941 endif; // page post_type
942 endif; // page-attributes
945 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
947 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
948 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
949 <label class="inline-edit-tags">
950 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
951 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
955 <?php endforeach; //$flat_taxonomies as $taxonomy ?>
957 <?php endif; // count( $flat_taxonomies ) && !$bulk ?>
959 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
962 <div class="inline-edit-group">
963 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
964 <label class="alignleft">
965 <span class="title"><?php _e( 'Comments' ); ?></span>
966 <select name="comment_status">
967 <option value=""><?php _e( '— No Change —' ); ?></option>
968 <option value="open"><?php _e( 'Allow' ); ?></option>
969 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
972 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
973 <label class="alignright">
974 <span class="title"><?php _e( 'Pings' ); ?></span>
975 <select name="ping_status">
976 <option value=""><?php _e( '— No Change —' ); ?></option>
977 <option value="open"><?php _e( 'Allow' ); ?></option>
978 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
984 <?php else : // $bulk ?>
986 <div class="inline-edit-group">
987 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
988 <label class="alignleft">
989 <input type="checkbox" name="comment_status" value="open" />
990 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
992 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
993 <label class="alignleft">
994 <input type="checkbox" name="ping_status" value="open" />
995 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1000 <?php endif; // $bulk
1001 endif; // post_type_supports comments or pings ?>
1003 <div class="inline-edit-group">
1004 <label class="inline-edit-status alignleft">
1005 <span class="title"><?php _e( 'Status' ); ?></span>
1006 <select name="_status">
1007 <?php if ( $bulk ) : ?>
1008 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1009 <?php endif; // $bulk ?>
1010 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1011 <option value="publish"><?php _e( 'Published' ); ?></option>
1012 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1013 <?php if ( $bulk ) : ?>
1014 <option value="private"><?php _e( 'Private' ) ?></option>
1015 <?php endif; // $bulk ?>
1017 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1018 <option value="draft"><?php _e( 'Draft' ); ?></option>
1022 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1024 <?php if ( $bulk ) : ?>
1026 <label class="alignright">
1027 <span class="title"><?php _e( 'Sticky' ); ?></span>
1028 <select name="sticky">
1029 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1030 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1031 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1035 <?php else : // $bulk ?>
1037 <label class="alignleft">
1038 <input type="checkbox" name="sticky" value="sticky" />
1039 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1042 <?php endif; // $bulk ?>
1044 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1050 if ( $bulk && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1051 $all_post_formats = get_post_format_strings();
1054 <label class="alignleft" for="post_format">
1055 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1056 <select name="post_format">
1057 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1060 foreach ( $all_post_formats as $slug => $format ) {
1062 <option value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $format ); ?></option>
1077 list( $columns ) = $this->get_column_info();
1079 foreach ( $columns as $column_name => $column_display_name ) {
1080 if ( isset( $core_columns[$column_name] ) )
1082 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
1085 <p class="submit inline-edit-save">
1086 <a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
1087 <?php if ( ! $bulk ) {
1088 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1090 <a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
1091 <span class="spinner"></span>
1093 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
1095 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1096 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1097 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1098 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1100 <span class="error" style="display:none"></span>
1101 <br class="clear" />
1108 </tbody></table></form>