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 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
498 list( $columns, $hidden ) = $this->get_column_info();
500 foreach ( $columns as $column_name => $column_display_name ) {
501 $class = "class=\"$column_name column-$column_name\"";
504 if ( in_array( $column_name, $hidden ) )
505 $style = ' style="display:none;"';
507 $attributes = "$class$style";
509 switch ( $column_name ) {
513 <th scope="row" class="check-column">
515 if ( $can_edit_post ) {
518 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
519 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
520 <div class="locked-indicator"></div>
529 $attributes = 'class="post-title page-title column-title"' . $style;
530 if ( $this->hierarchical_display ) {
531 if ( 0 == $level && (int) $post->post_parent > 0 ) {
532 //sent level 0 by accident, by default, or because we don't know the actual level
533 $find_main_page = (int) $post->post_parent;
534 while ( $find_main_page > 0 ) {
535 $parent = get_post( $find_main_page );
537 if ( is_null( $parent ) )
541 $find_main_page = (int) $parent->post_parent;
543 if ( !isset( $parent_name ) ) {
544 /** This filter is documented in wp-includes/post-template.php */
545 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
551 $pad = str_repeat( '— ', $level );
552 echo "<td $attributes><strong>";
554 if ( $format = get_post_format( $post->ID ) ) {
555 $label = get_post_format_string( $format );
557 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> ";
560 if ( $can_edit_post && $post->post_status != 'trash' ) {
561 echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
565 _post_states( $post );
567 if ( isset( $parent_name ) )
568 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
572 if ( $can_edit_post && $post->post_status != 'trash' ) {
573 if ( $lock_holder ) {
574 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
575 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
577 $locked_avatar = $locked_text = '';
580 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
583 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
587 if ( $can_edit_post && 'trash' != $post->post_status ) {
588 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
589 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
591 if ( current_user_can( 'delete_post', $post->ID ) ) {
592 if ( 'trash' == $post->post_status )
593 $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>";
594 elseif ( EMPTY_TRASH_DAYS )
595 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
596 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
597 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
599 if ( $post_type_object->public ) {
600 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
601 if ( $can_edit_post )
602 $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>';
603 } elseif ( 'trash' != $post->post_status ) {
604 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
608 $actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post );
609 echo $this->row_actions( $actions );
611 get_inline_data( $post );
616 if ( '0000-00-00 00:00:00' == $post->post_date ) {
617 $t_time = $h_time = __( 'Unpublished' );
620 $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
621 $m_time = $post->post_date;
622 $time = get_post_time( 'G', true, $post );
624 $time_diff = time() - $time;
626 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
627 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
629 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
632 echo '<td ' . $attributes . '>';
633 if ( 'excerpt' == $mode )
634 echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
636 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
638 if ( 'publish' == $post->post_status ) {
640 } elseif ( 'future' == $post->post_status ) {
641 if ( $time_diff > 0 )
642 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
646 _e( 'Last Modified' );
653 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
655 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
657 $this->comments_bubble( $post->ID, $pending_comments );
665 <td <?php echo $attributes ?>><?php
666 printf( '<a href="%s">%s</a>',
667 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
675 if ( 'categories' == $column_name )
676 $taxonomy = 'category';
677 elseif ( 'tags' == $column_name )
678 $taxonomy = 'post_tag';
679 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
680 $taxonomy = substr( $column_name, 9 );
685 $taxonomy_object = get_taxonomy( $taxonomy );
686 echo '<td ' . $attributes . '>';
687 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
689 foreach ( $terms as $t ) {
690 $posts_in_term_qv = array();
691 if ( 'post' != $post->post_type )
692 $posts_in_term_qv['post_type'] = $post->post_type;
693 if ( $taxonomy_object->query_var ) {
694 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
696 $posts_in_term_qv['taxonomy'] = $taxonomy;
697 $posts_in_term_qv['term'] = $t->slug;
700 $out[] = sprintf( '<a href="%s">%s</a>',
701 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
702 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
705 /* translators: used between list items, there is a space after the comma */
706 echo join( __( ', ' ), $out );
714 <td <?php echo $attributes ?>><?php
715 if ( is_post_type_hierarchical( $post->post_type ) )
716 do_action( 'manage_pages_custom_column', $column_name, $post->ID );
718 do_action( 'manage_posts_custom_column', $column_name, $post->ID );
719 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
728 $GLOBALS['post'] = $global_post;
732 * Outputs the hidden row displayed when inline editing
736 function inline_edit() {
739 $screen = $this->screen;
741 $post = get_default_post_to_edit( $screen->post_type );
742 $post_type_object = get_post_type_object( $screen->post_type );
744 $taxonomy_names = get_object_taxonomies( $screen->post_type );
745 $hierarchical_taxonomies = array();
746 $flat_taxonomies = array();
747 foreach ( $taxonomy_names as $taxonomy_name ) {
748 $taxonomy = get_taxonomy( $taxonomy_name );
750 if ( !$taxonomy->show_ui )
753 if ( $taxonomy->hierarchical )
754 $hierarchical_taxonomies[] = $taxonomy;
756 $flat_taxonomies[] = $taxonomy;
759 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
760 $can_publish = current_user_can( $post_type_object->cap->publish_posts );
761 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
765 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
767 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
769 while ( $bulk < 2 ) { ?>
771 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
772 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}";
773 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
775 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
776 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
779 if ( post_type_supports( $screen->post_type, 'title' ) ) :
781 <div id="bulk-title-div">
782 <div id="bulk-titles"></div>
785 <?php else : // $bulk ?>
788 <span class="title"><?php _e( 'Title' ); ?></span>
789 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
793 <span class="title"><?php _e( 'Slug' ); ?></span>
794 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
797 <?php endif; // $bulk
798 endif; // post_type_supports title ?>
800 <?php if ( !$bulk ) : ?>
801 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
802 <div class="inline-edit-date">
803 <?php touch_time( 1, 1, 0, 1 ); ?>
806 <?php endif; // $bulk
808 if ( post_type_supports( $screen->post_type, 'author' ) ) :
809 $authors_dropdown = '';
811 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
813 'hide_if_only_one_author' => false,
815 'name' => 'post_author',
821 $users_opt['show_option_none'] = __( '— No Change —' );
823 if ( $authors = wp_dropdown_users( $users_opt ) ) :
824 $authors_dropdown = '<label class="inline-edit-author">';
825 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
826 $authors_dropdown .= $authors;
827 $authors_dropdown .= '</label>';
832 <?php if ( !$bulk ) echo $authors_dropdown;
833 endif; // post_type_supports author
835 if ( !$bulk && $can_publish ) :
838 <div class="inline-edit-group">
839 <label class="alignleft">
840 <span class="title"><?php _e( 'Password' ); ?></span>
841 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
844 <em style="margin:5px 10px 0 0" class="alignleft">
846 /* translators: Between password field and private checkbox on post quick edit interface */
847 echo __( '–OR–' );
850 <label class="alignleft inline-edit-private">
851 <input type="checkbox" name="keep_private" value="private" />
852 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
860 <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
862 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
864 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
866 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
867 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
868 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
869 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
872 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
876 <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
878 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
881 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
882 echo $authors_dropdown;
884 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
886 if ( $post_type_object->hierarchical ) :
889 <span class="title"><?php _e( 'Parent' ); ?></span>
891 $dropdown_args = array(
892 'post_type' => $post_type_object->name,
893 'selected' => $post->post_parent,
894 'name' => 'post_parent',
895 'show_option_none' => __( 'Main Page (no parent)' ),
896 'option_none_value' => 0,
897 'sort_column' => 'menu_order, post_title',
901 $dropdown_args['show_option_no_change'] = __( '— No Change —' );
902 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
903 wp_dropdown_pages( $dropdown_args );
908 endif; // hierarchical
913 <span class="title"><?php _e( 'Order' ); ?></span>
914 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
917 <?php endif; // !$bulk
919 if ( 'page' == $screen->post_type ) :
923 <span class="title"><?php _e( 'Template' ); ?></span>
924 <select name="page_template">
925 <?php if ( $bulk ) : ?>
926 <option value="-1"><?php _e( '— No Change —' ); ?></option>
927 <?php endif; // $bulk ?>
928 <option value="default"><?php _e( 'Default Template' ); ?></option>
929 <?php page_template_dropdown() ?>
934 endif; // page post_type
935 endif; // page-attributes
938 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
940 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
941 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
942 <label class="inline-edit-tags">
943 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
944 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
948 <?php endforeach; //$flat_taxonomies as $taxonomy ?>
950 <?php endif; // count( $flat_taxonomies ) && !$bulk ?>
952 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
955 <div class="inline-edit-group">
956 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
957 <label class="alignleft">
958 <span class="title"><?php _e( 'Comments' ); ?></span>
959 <select name="comment_status">
960 <option value=""><?php _e( '— No Change —' ); ?></option>
961 <option value="open"><?php _e( 'Allow' ); ?></option>
962 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
965 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
966 <label class="alignright">
967 <span class="title"><?php _e( 'Pings' ); ?></span>
968 <select name="ping_status">
969 <option value=""><?php _e( '— No Change —' ); ?></option>
970 <option value="open"><?php _e( 'Allow' ); ?></option>
971 <option value="closed"><?php _e( 'Do not allow' ); ?></option>
977 <?php else : // $bulk ?>
979 <div class="inline-edit-group">
980 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
981 <label class="alignleft">
982 <input type="checkbox" name="comment_status" value="open" />
983 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
985 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
986 <label class="alignleft">
987 <input type="checkbox" name="ping_status" value="open" />
988 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
993 <?php endif; // $bulk
994 endif; // post_type_supports comments or pings ?>
996 <div class="inline-edit-group">
997 <label class="inline-edit-status alignleft">
998 <span class="title"><?php _e( 'Status' ); ?></span>
999 <select name="_status">
1000 <?php if ( $bulk ) : ?>
1001 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1002 <?php endif; // $bulk ?>
1003 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1004 <option value="publish"><?php _e( 'Published' ); ?></option>
1005 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1006 <?php if ( $bulk ) : ?>
1007 <option value="private"><?php _e( 'Private' ) ?></option>
1008 <?php endif; // $bulk ?>
1010 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1011 <option value="draft"><?php _e( 'Draft' ); ?></option>
1015 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1017 <?php if ( $bulk ) : ?>
1019 <label class="alignright">
1020 <span class="title"><?php _e( 'Sticky' ); ?></span>
1021 <select name="sticky">
1022 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1023 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1024 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1028 <?php else : // $bulk ?>
1030 <label class="alignleft">
1031 <input type="checkbox" name="sticky" value="sticky" />
1032 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1035 <?php endif; // $bulk ?>
1037 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1043 if ( $bulk && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1044 $all_post_formats = get_post_format_strings();
1047 <label class="alignleft" for="post_format">
1048 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1049 <select name="post_format">
1050 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1053 foreach ( $all_post_formats as $slug => $format ) {
1055 <option value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $format ); ?></option>
1070 list( $columns ) = $this->get_column_info();
1072 foreach ( $columns as $column_name => $column_display_name ) {
1073 if ( isset( $core_columns[$column_name] ) )
1075 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
1078 <p class="submit inline-edit-save">
1079 <a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
1080 <?php if ( ! $bulk ) {
1081 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1083 <a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
1084 <span class="spinner"></span>
1086 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
1088 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1089 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1090 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1091 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1093 <span class="error" style="display:none"></span>
1094 <br class="clear" />
1101 </tbody></table></form>