]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/includes/class-wp-posts-list-table.php
WordPress 4.3
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-posts-list-table.php
1 <?php
2 /**
3  * Posts List Table class.
4  *
5  * @package WordPress
6  * @subpackage List_Table
7  * @since 3.1.0
8  * @access private
9  */
10 class WP_Posts_List_Table extends WP_List_Table {
11
12         /**
13          * Whether the items should be displayed hierarchically or linearly
14          *
15          * @since 3.1.0
16          * @var bool
17          * @access protected
18          */
19         protected $hierarchical_display;
20
21         /**
22          * Holds the number of pending comments for each post
23          *
24          * @since 3.1.0
25          * @var int
26          * @access protected
27          */
28         protected $comment_pending_count;
29
30         /**
31          * Holds the number of posts for this user
32          *
33          * @since 3.1.0
34          * @var int
35          * @access private
36          */
37         private $user_posts_count;
38
39         /**
40          * Holds the number of posts which are sticky.
41          *
42          * @since 3.1.0
43          * @var int
44          * @access private
45          */
46         private $sticky_posts_count = 0;
47
48         private $is_trash;
49
50         /**
51          * Current level for output.
52          *
53          * @since 4.3.0
54          * @access protected
55          * @var int
56          */
57         protected $current_level = 0;
58
59         /**
60          * Constructor.
61          *
62          * @since 3.1.0
63          * @access public
64          *
65          * @see WP_List_Table::__construct() for more information on default arguments.
66          *
67          * @global object $post_type_object
68          * @global wpdb   $wpdb
69          *
70          * @param array $args An associative array of arguments.
71          */
72         public function __construct( $args = array() ) {
73                 global $post_type_object, $wpdb;
74
75                 parent::__construct( array(
76                         'plural' => 'posts',
77                         'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
78                 ) );
79
80                 $post_type = $this->screen->post_type;
81                 $post_type_object = get_post_type_object( $post_type );
82
83                 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
84                         $exclude_states = get_post_stati( array( 'show_in_admin_all_list' => false ) );
85                         $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
86                                 SELECT COUNT( 1 ) FROM $wpdb->posts
87                                 WHERE post_type = %s AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
88                                 AND post_author = %d
89                         ", $post_type, get_current_user_id() ) );
90
91                         if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) )
92                                 $_GET['author'] = get_current_user_id();
93                 }
94
95                 if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
96                         $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
97                         $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 ) );
98                 }
99         }
100
101         /**
102          * Sets whether the table layout should be hierarchical or not.
103          *
104          * @since 4.2.0
105          *
106          * @param bool $display Whether the table layout should be hierarchical.
107          */
108         public function set_hierarchical_display( $display ) {
109                 $this->hierarchical_display = $display;
110         }
111
112         /**
113          *
114          * @return bool
115          */
116         public function ajax_user_can() {
117                 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
118         }
119
120         /**
121          *
122          * @global array    $avail_post_stati
123          * @global WP_Query $wp_query
124          * @global int      $per_page
125          * @global string   $mode
126          */
127         public function prepare_items() {
128                 global $avail_post_stati, $wp_query, $per_page, $mode;
129
130                 $avail_post_stati = wp_edit_posts_query();
131
132                 $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
133
134                 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
135
136                 $post_type = $this->screen->post_type;
137                 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
138
139                 /** This filter is documented in wp-admin/includes/post.php */
140                 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
141
142                 if ( $this->hierarchical_display )
143                         $total_pages = ceil( $total_items / $per_page );
144                 else
145                         $total_pages = $wp_query->max_num_pages;
146
147                 if ( ! empty( $_REQUEST['mode'] ) ) {
148                         $mode = $_REQUEST['mode'] == 'excerpt' ? 'excerpt' : 'list';
149                         set_user_setting ( 'posts_list_mode', $mode );
150                 } else {
151                         $mode = get_user_setting ( 'posts_list_mode', 'list' );
152                 }
153
154                 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
155
156                 $this->set_pagination_args( array(
157                         'total_items' => $total_items,
158                         'total_pages' => $total_pages,
159                         'per_page' => $per_page
160                 ) );
161         }
162
163         /**
164          *
165          * @return bool
166          */
167         public function has_items() {
168                 return have_posts();
169         }
170
171         /**
172          * @access public
173          */
174         public function no_items() {
175                 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
176                         echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
177                 else
178                         echo get_post_type_object( $this->screen->post_type )->labels->not_found;
179         }
180
181         /**
182          * Determine if the current view is the "All" view.
183          *
184          * @since 4.2.0
185          *
186          * @return bool Whether the current view is the "All" view.
187          */
188         protected function is_base_request() {
189                 if ( empty( $_GET ) ) {
190                         return true;
191                 } elseif ( 1 === count( $_GET ) && ! empty( $_GET['post_type'] ) ) {
192                         return $this->screen->post_type === $_GET['post_type'];
193                 }
194         }
195
196         /**
197          *
198          * @global array $locked_post_status This seems to be deprecated.
199          * @global array $avail_post_stati
200          * @return array
201          */
202         protected function get_views() {
203                 global $locked_post_status, $avail_post_stati;
204
205                 $post_type = $this->screen->post_type;
206
207                 if ( !empty($locked_post_status) )
208                         return array();
209
210                 $status_links = array();
211                 $num_posts = wp_count_posts( $post_type, 'readable' );
212                 $class = '';
213                 $allposts = '';
214
215                 $current_user_id = get_current_user_id();
216
217                 if ( $this->user_posts_count ) {
218                         if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
219                                 $class = ' class="current"';
220                         $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>';
221                         $allposts = '&all_posts=1';
222                         $class = '';
223                 }
224
225                 $total_posts = array_sum( (array) $num_posts );
226
227                 // Subtract post types that are not included in the admin all list.
228                 foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
229                         $total_posts -= $num_posts->$state;
230
231                 if ( empty( $class ) && ( ( $this->is_base_request() && ! $this->user_posts_count ) || isset( $_REQUEST['all_posts'] ) ) ) {
232                         $class =  ' class="current"';
233                 }
234
235                 $all_inner_html = sprintf(
236                         _nx(
237                                 'All <span class="count">(%s)</span>',
238                                 'All <span class="count">(%s)</span>',
239                                 $total_posts,
240                                 'posts'
241                         ),
242                         number_format_i18n( $total_posts )
243                 );
244
245                 $status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . $all_inner_html . '</a>';
246
247                 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
248                         $class = '';
249
250                         $status_name = $status->name;
251
252                         if ( !in_array( $status_name, $avail_post_stati ) )
253                                 continue;
254
255                         if ( empty( $num_posts->$status_name ) )
256                                 continue;
257
258                         if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
259                                 $class = ' class="current"';
260
261                         $status_links[$status_name] = "<a href='edit.php?post_status=$status_name&amp;post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
262                 }
263
264                 if ( ! empty( $this->sticky_posts_count ) ) {
265                         $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
266
267                         $sticky_link = array( 'sticky' => "<a href='edit.php?post_type=$post_type&amp;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>' );
268
269                         // Sticky comes after Publish, or if not listed, after All.
270                         $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
271                         $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
272                 }
273
274                 return $status_links;
275         }
276
277         /**
278          *
279          * @return array
280          */
281         protected function get_bulk_actions() {
282                 $actions = array();
283                 $post_type_obj = get_post_type_object( $this->screen->post_type );
284
285                 if ( $this->is_trash ) {
286                         $actions['untrash'] = __( 'Restore' );
287                 } else {
288                         $actions['edit'] = __( 'Edit' );
289                 }
290
291                 if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
292                         if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
293                                 $actions['delete'] = __( 'Delete Permanently' );
294                         } else {
295                                 $actions['trash'] = __( 'Move to Trash' );
296                         }
297                 }
298
299                 return $actions;
300         }
301
302         /**
303          * @global int $cat
304          * @param string $which
305          */
306         protected function extra_tablenav( $which ) {
307                 global $cat;
308 ?>
309                 <div class="alignleft actions">
310 <?php
311                 if ( 'top' == $which && !is_singular() ) {
312
313                         $this->months_dropdown( $this->screen->post_type );
314
315                         if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
316                                 $dropdown_options = array(
317                                         'show_option_all' => __( 'All categories' ),
318                                         'hide_empty' => 0,
319                                         'hierarchical' => 1,
320                                         'show_count' => 0,
321                                         'orderby' => 'name',
322                                         'selected' => $cat
323                                 );
324
325                                 echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
326                                 wp_dropdown_categories( $dropdown_options );
327                         }
328
329                         /**
330                          * Fires before the Filter button on the Posts and Pages list tables.
331                          *
332                          * The Filter button allows sorting by date and/or category on the
333                          * Posts list table, and sorting by date on the Pages list table.
334                          *
335                          * @since 2.1.0
336                          */
337                         do_action( 'restrict_manage_posts' );
338
339                         submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
340                 }
341
342                 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
343                         submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
344                 }
345 ?>
346                 </div>
347 <?php
348         }
349
350         /**
351          *
352          * @return string
353          */
354         public function current_action() {
355                 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
356                         return 'delete_all';
357
358                 return parent::current_action();
359         }
360
361         /**
362          * @global string $mode
363          * @param string $which
364          */
365         protected function pagination( $which ) {
366                 global $mode;
367
368                 parent::pagination( $which );
369
370                 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
371                         $this->view_switcher( $mode );
372         }
373
374         /**
375          *
376          * @return array
377          */
378         protected function get_table_classes() {
379                 return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
380         }
381
382         /**
383          *
384          * @return array
385          */
386         public function get_columns() {
387                 $post_type = $this->screen->post_type;
388
389                 $posts_columns = array();
390
391                 $posts_columns['cb'] = '<input type="checkbox" />';
392
393                 /* translators: manage posts column name */
394                 $posts_columns['title'] = _x( 'Title', 'column name' );
395
396                 if ( post_type_supports( $post_type, 'author' ) ) {
397                         $posts_columns['author'] = __( 'Author' );
398                 }
399
400                 $taxonomies = get_object_taxonomies( $post_type, 'objects' );
401                 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
402
403                 /**
404                  * Filter the taxonomy columns in the Posts list table.
405                  *
406                  * The dynamic portion of the hook name, `$post_type`, refers to the post
407                  * type slug.
408                  *
409                  * @since 3.5.0
410                  *
411                  * @param array  $taxonomies Array of taxonomies to show columns for.
412                  * @param string $post_type  The post type.
413                  */
414                 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
415                 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
416
417                 foreach ( $taxonomies as $taxonomy ) {
418                         if ( 'category' == $taxonomy )
419                                 $column_key = 'categories';
420                         elseif ( 'post_tag' == $taxonomy )
421                                 $column_key = 'tags';
422                         else
423                                 $column_key = 'taxonomy-' . $taxonomy;
424
425                         $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
426                 }
427
428                 $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
429                 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
430                         $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
431
432                 $posts_columns['date'] = __( 'Date' );
433
434                 if ( 'page' == $post_type ) {
435
436                         /**
437                          * Filter the columns displayed in the Pages list table.
438                          *
439                          * @since 2.5.0
440                          *
441                          * @param array $post_columns An array of column names.
442                          */
443                         $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
444                 } else {
445
446                         /**
447                          * Filter the columns displayed in the Posts list table.
448                          *
449                          * @since 1.5.0
450                          *
451                          * @param array  $posts_columns An array of column names.
452                          * @param string $post_type     The post type slug.
453                          */
454                         $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
455                 }
456
457                 /**
458                  * Filter the columns displayed in the Posts list table for a specific post type.
459                  *
460                  * The dynamic portion of the hook name, `$post_type`, refers to the post type slug.
461                  *
462                  * @since 3.0.0
463                  *
464                  * @param array $post_columns An array of column names.
465                  */
466                 return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
467         }
468
469         /**
470          *
471          * @return array
472          */
473         protected function get_sortable_columns() {
474                 return array(
475                         'title'    => 'title',
476                         'parent'   => 'parent',
477                         'comments' => 'comment_count',
478                         'date'     => array( 'date', true )
479                 );
480         }
481
482         /**
483          * @global WP_Query $wp_query
484          * @global int $per_page
485          * @param array $posts
486          * @param int $level
487          */
488         public function display_rows( $posts = array(), $level = 0 ) {
489                 global $wp_query, $per_page;
490
491                 if ( empty( $posts ) )
492                         $posts = $wp_query->posts;
493
494                 add_filter( 'the_title', 'esc_html' );
495
496                 if ( $this->hierarchical_display ) {
497                         $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
498                 } else {
499                         $this->_display_rows( $posts, $level );
500                 }
501         }
502
503         /**
504          * @global string $mode
505          * @param array $posts
506          * @param int $level
507          */
508         private function _display_rows( $posts, $level = 0 ) {
509                 global $mode;
510
511                 // Create array of post IDs.
512                 $post_ids = array();
513
514                 foreach ( $posts as $a_post )
515                         $post_ids[] = $a_post->ID;
516
517                 $this->comment_pending_count = get_pending_comments_num( $post_ids );
518
519                 foreach ( $posts as $post )
520                         $this->single_row( $post, $level );
521         }
522
523         /**
524          * @global wpdb    $wpdb
525          * @global WP_Post $post
526          * @param array $pages
527          * @param int $pagenum
528          * @param int $per_page
529          */
530         private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
531                 global $wpdb;
532
533                 $level = 0;
534
535                 if ( ! $pages ) {
536                         $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
537
538                         if ( ! $pages )
539                                 return;
540                 }
541
542                 /*
543                  * Arrange pages into two parts: top level pages and children_pages
544                  * children_pages is two dimensional array, eg.
545                  * children_pages[10][] contains all sub-pages whose parent is 10.
546                  * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
547                  * If searching, ignore hierarchy and treat everything as top level
548                  */
549                 if ( empty( $_REQUEST['s'] ) ) {
550
551                         $top_level_pages = array();
552                         $children_pages = array();
553
554                         foreach ( $pages as $page ) {
555
556                                 // Catch and repair bad pages.
557                                 if ( $page->post_parent == $page->ID ) {
558                                         $page->post_parent = 0;
559                                         $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
560                                         clean_post_cache( $page );
561                                 }
562
563                                 if ( 0 == $page->post_parent )
564                                         $top_level_pages[] = $page;
565                                 else
566                                         $children_pages[ $page->post_parent ][] = $page;
567                         }
568
569                         $pages = &$top_level_pages;
570                 }
571
572                 $count = 0;
573                 $start = ( $pagenum - 1 ) * $per_page;
574                 $end = $start + $per_page;
575                 $to_display = array();
576
577                 foreach ( $pages as $page ) {
578                         if ( $count >= $end )
579                                 break;
580
581                         if ( $count >= $start ) {
582                                 $to_display[$page->ID] = $level;
583                         }
584
585                         $count++;
586
587                         if ( isset( $children_pages ) )
588                                 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
589                 }
590
591                 // If it is the last pagenum and there are orphaned pages, display them with paging as well.
592                 if ( isset( $children_pages ) && $count < $end ){
593                         foreach ( $children_pages as $orphans ){
594                                 foreach ( $orphans as $op ) {
595                                         if ( $count >= $end )
596                                                 break;
597
598                                         if ( $count >= $start ) {
599                                                 $to_display[$op->ID] = 0;
600                                         }
601
602                                         $count++;
603                                 }
604                         }
605                 }
606
607                 $ids = array_keys( $to_display );
608                 _prime_post_caches( $ids );
609
610                 if ( ! isset( $GLOBALS['post'] ) ) {
611                         $GLOBALS['post'] = reset( $ids );
612                 }
613
614                 foreach ( $to_display as $page_id => $level ) {
615                         echo "\t";
616                         $this->single_row( $page_id, $level );
617                 }
618         }
619
620         /**
621          * Given a top level page ID, display the nested hierarchy of sub-pages
622          * together with paging support
623          *
624          * @since 3.1.0 (Standalone function exists since 2.6.0)
625          * @since 4.2.0 Added the `$to_display` parameter.
626          *
627          * @param array $children_pages
628          * @param int $count
629          * @param int $parent
630          * @param int $level
631          * @param int $pagenum
632          * @param int $per_page
633          * @param array $to_display List of pages to be displayed. Passed by reference.
634          */
635         private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
636                 if ( ! isset( $children_pages[$parent] ) )
637                         return;
638
639                 $start = ( $pagenum - 1 ) * $per_page;
640                 $end = $start + $per_page;
641
642                 foreach ( $children_pages[$parent] as $page ) {
643                         if ( $count >= $end )
644                                 break;
645
646                         // If the page starts in a subtree, print the parents.
647                         if ( $count == $start && $page->post_parent > 0 ) {
648                                 $my_parents = array();
649                                 $my_parent = $page->post_parent;
650                                 while ( $my_parent ) {
651                                         // Get the ID from the list or the attribute if my_parent is an object
652                                         $parent_id = $my_parent;
653                                         if ( is_object( $my_parent ) ) {
654                                                 $parent_id = $my_parent->ID;
655                                         }
656
657                                         $my_parent = get_post( $parent_id );
658                                         $my_parents[] = $my_parent;
659                                         if ( !$my_parent->post_parent )
660                                                 break;
661                                         $my_parent = $my_parent->post_parent;
662                                 }
663                                 $num_parents = count( $my_parents );
664                                 while ( $my_parent = array_pop( $my_parents ) ) {
665                                         $to_display[$my_parent->ID] = $level - $num_parents;
666                                         $num_parents--;
667                                 }
668                         }
669
670                         if ( $count >= $start ) {
671                                 $to_display[$page->ID] = $level;
672                         }
673
674                         $count++;
675
676                         $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
677                 }
678
679                 unset( $children_pages[$parent] ); //required in order to keep track of orphans
680         }
681
682         /**
683          * Handles the checkbox column output.
684          *
685          * @since 4.3.0
686          * @access public
687          *
688          * @param WP_Post $post The current WP_Post object.
689          */
690         public function column_cb( $post ) {
691                 if ( current_user_can( 'edit_post', $post->ID ) ): ?>
692                         <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php
693                                 printf( __( 'Select %s' ), _draft_or_post_title() );
694                         ?></label>
695                         <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
696                         <div class="locked-indicator"></div>
697                 <?php endif;
698         }
699
700         /**
701          * @since 4.3.0
702          * @access protected
703          *
704          * @param WP_Post $post
705          * @param string  $classes
706          * @param string  $data
707          * @param string  $primary
708          */
709         protected function _column_title( $post, $classes, $data, $primary ) {
710                 echo '<td class="' . $classes . ' page-title" ', $data, '>';
711                 echo $this->column_title( $post );
712                 echo $this->handle_row_actions( $post, 'title', $primary );
713                 echo '</td>';
714         }
715
716         /**
717          * Handles the title column output.
718          *
719          * @since 4.3.0
720          * @access public
721          *
722          * @global string $mode
723          *
724          * @param WP_Post $post The current WP_Post object.
725          */
726         public function column_title( $post ) {
727                 global $mode;
728
729                 if ( $this->hierarchical_display ) {
730                         if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) {
731                                 // Sent level 0 by accident, by default, or because we don't know the actual level.
732                                 $find_main_page = (int) $post->post_parent;
733                                 while ( $find_main_page > 0 ) {
734                                         $parent = get_post( $find_main_page );
735
736                                         if ( is_null( $parent ) ) {
737                                                 break;
738                                         }
739
740                                         $this->current_level++;
741                                         $find_main_page = (int) $parent->post_parent;
742
743                                         if ( ! isset( $parent_name ) ) {
744                                                 /** This filter is documented in wp-includes/post-template.php */
745                                                 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
746                                         }
747                                 }
748                         }
749                 }
750
751                 $pad = str_repeat( '&#8212; ', $this->current_level );
752                 echo "<strong>";
753
754                 $format = get_post_format( $post->ID );
755                 if ( $format ) {
756                         $label = get_post_format_string( $format );
757
758                         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> ";
759                 }
760
761                 $can_edit_post = current_user_can( 'edit_post', $post->ID );
762                 $title = _draft_or_post_title();
763
764                 if ( $can_edit_post && $post->post_status != 'trash' ) {
765                         $edit_link = get_edit_post_link( $post->ID );
766                         echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . $pad . $title . '</a>';
767                 } else {
768                         echo $pad . $title;
769                 }
770                 _post_states( $post );
771
772                 if ( isset( $parent_name ) ) {
773                         $post_type_object = get_post_type_object( $post->post_type );
774                         echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
775                 }
776                 echo "</strong>\n";
777
778                 if ( $can_edit_post && $post->post_status != 'trash' ) {
779                         $lock_holder = wp_check_post_lock( $post->ID );
780
781                         if ( $lock_holder ) {
782                                 $lock_holder = get_userdata( $lock_holder );
783                                 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
784                                 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
785                         } else {
786                                 $locked_avatar = $locked_text = '';
787                         }
788
789                         echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
790                 }
791
792                 if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) {
793                         the_excerpt();
794                 }
795
796                 get_inline_data( $post );
797         }
798
799         /**
800          * Handles the post date column output.
801          *
802          * @since 4.3.0
803          * @access public
804          *
805          * @global string $mode
806          *
807          * @param WP_Post $post The current WP_Post object.
808          */
809         public function column_date( $post ) {
810                 global $mode;
811
812                 if ( '0000-00-00 00:00:00' == $post->post_date ) {
813                         $t_time = $h_time = __( 'Unpublished' );
814                         $time_diff = 0;
815                 } else {
816                         $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
817                         $m_time = $post->post_date;
818                         $time = get_post_time( 'G', true, $post );
819
820                         $time_diff = time() - $time;
821
822                         if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
823                                 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
824                         } else {
825                                 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
826                         }
827                 }
828
829                 if ( 'excerpt' == $mode ) {
830                         /**
831                          * Filter the published time of the post.
832                          *
833                          * If $mode equals 'excerpt', the published time and date are both displayed.
834                          * If $mode equals 'list' (default), the publish date is displayed, with the
835                          * time and date together available as an abbreviation definition.
836                          *
837                          * @since 2.5.1
838                          *
839                          * @param array   $t_time      The published time.
840                          * @param WP_Post $post        Post object.
841                          * @param string  $column_name The column name.
842                          * @param string  $mode        The list display mode ('excerpt' or 'list').
843                          */
844                         echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
845                 } else {
846
847                         /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
848                         echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>';
849                 }
850                 echo '<br />';
851                 if ( 'publish' == $post->post_status ) {
852                         _e( 'Published' );
853                 } elseif ( 'future' == $post->post_status ) {
854                         if ( $time_diff > 0 ) {
855                                 echo '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>';
856                         } else {
857                                 _e( 'Scheduled' );
858                         }
859                 } else {
860                         _e( 'Last Modified' );
861                 }
862         }
863
864         /**
865          * Handles the comments column output.
866          *
867          * @since 4.3.0
868          * @access public
869          *
870          * @param WP_Post $post The current WP_Post object.
871          */
872         public function column_comments( $post ) {
873                 ?>
874                 <div class="post-com-count-wrapper">
875                 <?php
876                         $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
877
878                         $this->comments_bubble( $post->ID, $pending_comments );
879                 ?>
880                 </div>
881                 <?php
882         }
883
884         /**
885          * Handles the post author column output.
886          *
887          * @since 4.3.0
888          * @access public
889          *
890          * @param WP_Post $post The current WP_Post object.
891          */
892         public function column_author( $post ) {
893                 printf( '<a href="%s">%s</a>',
894                         esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
895                         get_the_author()
896                 );
897         }
898
899         /**
900          * Handles the default column output.
901          *
902          * @since 4.3.0
903          * @access public
904          *
905          * @param WP_Post $post        The current WP_Post object.
906          * @param string  $column_name The current column name.
907          */
908         public function column_default( $post, $column_name ) {
909                 if ( 'categories' == $column_name ) {
910                         $taxonomy = 'category';
911                 } elseif ( 'tags' == $column_name ) {
912                         $taxonomy = 'post_tag';
913                 } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
914                         $taxonomy = substr( $column_name, 9 );
915                 } else {
916                         $taxonomy = false;
917                 }
918                 if ( $taxonomy ) {
919                         $taxonomy_object = get_taxonomy( $taxonomy );
920                         $terms = get_the_terms( $post->ID, $taxonomy );
921                         if ( is_array( $terms ) ) {
922                                 $out = array();
923                                 foreach ( $terms as $t ) {
924                                         $posts_in_term_qv = array();
925                                         if ( 'post' != $post->post_type ) {
926                                                 $posts_in_term_qv['post_type'] = $post->post_type;
927                                         }
928                                         if ( $taxonomy_object->query_var ) {
929                                                 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
930                                         } else {
931                                                 $posts_in_term_qv['taxonomy'] = $taxonomy;
932                                                 $posts_in_term_qv['term'] = $t->slug;
933                                         }
934
935                                         $out[] = sprintf( '<a href="%s">%s</a>',
936                                                 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
937                                                 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
938                                         );
939                                 }
940                                 /* translators: used between list items, there is a space after the comma */
941                                 echo join( __( ', ' ), $out );
942                         } else {
943                                 echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
944                         }
945                         return;
946                 }
947
948                 if ( is_post_type_hierarchical( $post->post_type ) ) {
949
950                         /**
951                          * Fires in each custom column on the Posts list table.
952                          *
953                          * This hook only fires if the current post type is hierarchical,
954                          * such as pages.
955                          *
956                          * @since 2.5.0
957                          *
958                          * @param string $column_name The name of the column to display.
959                          * @param int    $post_id     The current post ID.
960                          */
961                         do_action( 'manage_pages_custom_column', $column_name, $post->ID );
962                 } else {
963
964                         /**
965                          * Fires in each custom column in the Posts list table.
966                          *
967                          * This hook only fires if the current post type is non-hierarchical,
968                          * such as posts.
969                          *
970                          * @since 1.5.0
971                          *
972                          * @param string $column_name The name of the column to display.
973                          * @param int    $post_id     The current post ID.
974                          */
975                         do_action( 'manage_posts_custom_column', $column_name, $post->ID );
976                 }
977
978                 /**
979                  * Fires for each custom column of a specific post type in the Posts list table.
980                  *
981                  * The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
982                  *
983                  * @since 3.1.0
984                  *
985                  * @param string $column_name The name of the column to display.
986                  * @param int    $post_id     The current post ID.
987                  */
988                 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
989         }
990
991         /**
992          * @global WP_Post $post
993          *
994          * @param int|WP_Post $post
995          * @param int         $level
996          */
997         public function single_row( $post, $level = 0 ) {
998                 $global_post = get_post();
999
1000                 $post = get_post( $post );
1001                 $this->current_level = $level;
1002
1003                 $GLOBALS['post'] = $post;
1004                 setup_postdata( $post );
1005
1006                 $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
1007
1008                 $lock_holder = wp_check_post_lock( $post->ID );
1009                 if ( $lock_holder ) {
1010                         $classes .= ' wp-locked';
1011                 }
1012
1013                 if ( $post->post_parent ) {
1014                     $count = count( get_post_ancestors( $post->ID ) );
1015                     $classes .= ' level-'. $count;
1016                 } else {
1017                     $classes .= ' level-0';
1018                 }
1019         ?>
1020                 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
1021                         <?php $this->single_row_columns( $post ); ?>
1022                 </tr>
1023         <?php
1024                 $GLOBALS['post'] = $global_post;
1025         }
1026
1027         /**
1028          * Gets the name of the default primary column.
1029          *
1030          * @since 4.3.0
1031          * @access protected
1032          *
1033          * @return string Name of the default primary column, in this case, 'title'.
1034          */
1035         protected function get_default_primary_column_name() {
1036                 return 'title';
1037         }
1038
1039         /**
1040          * Generates and displays row action links.
1041          *
1042          * @since 4.3.0
1043          * @access protected
1044          *
1045          * @param object $post        Post being acted upon.
1046          * @param string $column_name Current column name.
1047          * @param string $primary     Primary column name.
1048          * @return string Row actions output for posts.
1049          */
1050         protected function handle_row_actions( $post, $column_name, $primary ) {
1051                 if ( $primary !== $column_name ) {
1052                         return '';
1053                 }
1054
1055                 $post_type_object = get_post_type_object( $post->post_type );
1056                 $can_edit_post = current_user_can( 'edit_post', $post->ID );
1057                 $actions = array();
1058
1059                 if ( $can_edit_post && 'trash' != $post->post_status ) {
1060                         $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
1061                         $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
1062                 }
1063
1064                 if ( current_user_can( 'delete_post', $post->ID ) ) {
1065                         if ( 'trash' == $post->post_status )
1066                                 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
1067                         elseif ( EMPTY_TRASH_DAYS )
1068                                 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
1069                         if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
1070                                 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
1071                 }
1072
1073                 if ( $post_type_object->public ) {
1074                         $title = _draft_or_post_title();
1075                         if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
1076                                 if ( $can_edit_post ) {
1077                                         $preview_link = set_url_scheme( get_permalink( $post->ID ) );
1078                                         /** This filter is documented in wp-admin/includes/meta-boxes.php */
1079                                         $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
1080                                         $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
1081                                 }
1082                         } elseif ( 'trash' != $post->post_status ) {
1083                                 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
1084                         }
1085                 }
1086
1087                 if ( is_post_type_hierarchical( $post->post_type ) ) {
1088
1089                         /**
1090                          * Filter the array of row action links on the Pages list table.
1091                          *
1092                          * The filter is evaluated only for hierarchical post types.
1093                          *
1094                          * @since 2.8.0
1095                          *
1096                          * @param array $actions An array of row action links. Defaults are
1097                          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
1098                          *                         'Delete Permanently', 'Preview', and 'View'.
1099                          * @param WP_Post $post The post object.
1100                          */
1101                         $actions = apply_filters( 'page_row_actions', $actions, $post );
1102                 } else {
1103
1104                         /**
1105                          * Filter the array of row action links on the Posts list table.
1106                          *
1107                          * The filter is evaluated only for non-hierarchical post types.
1108                          *
1109                          * @since 2.8.0
1110                          *
1111                          * @param array $actions An array of row action links. Defaults are
1112                          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
1113                          *                         'Delete Permanently', 'Preview', and 'View'.
1114                          * @param WP_Post $post The post object.
1115                          */
1116                         $actions = apply_filters( 'post_row_actions', $actions, $post );
1117                 }
1118
1119                 return $this->row_actions( $actions );
1120         }
1121
1122         /**
1123          * Outputs the hidden row displayed when inline editing
1124          *
1125          * @since 3.1.0
1126          *
1127          * @global string $mode
1128          */
1129         public function inline_edit() {
1130                 global $mode;
1131
1132                 $screen = $this->screen;
1133
1134                 $post = get_default_post_to_edit( $screen->post_type );
1135                 $post_type_object = get_post_type_object( $screen->post_type );
1136
1137                 $taxonomy_names = get_object_taxonomies( $screen->post_type );
1138                 $hierarchical_taxonomies = array();
1139                 $flat_taxonomies = array();
1140                 foreach ( $taxonomy_names as $taxonomy_name ) {
1141
1142                         $taxonomy = get_taxonomy( $taxonomy_name );
1143
1144                         $show_in_quick_edit = $taxonomy->show_in_quick_edit;
1145
1146                         /**
1147                          * Filter whether the current taxonomy should be shown in the Quick Edit panel.
1148                          *
1149                          * @since 4.2.0
1150                          *
1151                          * @param bool   $show_in_quick_edit Whether to show the current taxonomy in Quick Edit.
1152                          * @param string $taxonomy_name      Taxonomy name.
1153                          * @param string $post_type          Post type of current Quick Edit post.
1154                          */
1155                         if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) {
1156                                 continue;
1157                         }
1158
1159                         if ( $taxonomy->hierarchical )
1160                                 $hierarchical_taxonomies[] = $taxonomy;
1161                         else
1162                                 $flat_taxonomies[] = $taxonomy;
1163                 }
1164
1165                 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
1166                 $can_publish = current_user_can( $post_type_object->cap->publish_posts );
1167                 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
1168
1169         ?>
1170
1171         <form method="get"><table style="display: none"><tbody id="inlineedit">
1172                 <?php
1173                 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
1174                 $bulk = 0;
1175                 while ( $bulk < 2 ) { ?>
1176
1177                 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
1178                         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}";
1179                 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
1180
1181                 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
1182                         <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
1183         <?php
1184
1185         if ( post_type_supports( $screen->post_type, 'title' ) ) :
1186                 if ( $bulk ) : ?>
1187                         <div id="bulk-title-div">
1188                                 <div id="bulk-titles"></div>
1189                         </div>
1190
1191         <?php else : // $bulk ?>
1192
1193                         <label>
1194                                 <span class="title"><?php _e( 'Title' ); ?></span>
1195                                 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1196                         </label>
1197
1198                         <label>
1199                                 <span class="title"><?php _e( 'Slug' ); ?></span>
1200                                 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
1201                         </label>
1202
1203         <?php endif; // $bulk
1204         endif; // post_type_supports title ?>
1205
1206         <?php if ( !$bulk ) : ?>
1207                         <fieldset class="inline-edit-date">
1208                         <legend><span class="title"><?php _e( 'Date' ); ?></span></legend>
1209                                 <?php touch_time( 1, 1, 0, 1 ); ?>
1210                         </fieldset>
1211                         <br class="clear" />
1212         <?php endif; // $bulk
1213
1214                 if ( post_type_supports( $screen->post_type, 'author' ) ) :
1215                         $authors_dropdown = '';
1216
1217                         if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
1218                                 $users_opt = array(
1219                                         'hide_if_only_one_author' => false,
1220                                         'who' => 'authors',
1221                                         'name' => 'post_author',
1222                                         'class'=> 'authors',
1223                                         'multi' => 1,
1224                                         'echo' => 0
1225                                 );
1226                                 if ( $bulk )
1227                                         $users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1228
1229                                 if ( $authors = wp_dropdown_users( $users_opt ) ) :
1230                                         $authors_dropdown  = '<label class="inline-edit-author">';
1231                                         $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
1232                                         $authors_dropdown .= $authors;
1233                                         $authors_dropdown .= '</label>';
1234                                 endif;
1235                         endif; // authors
1236         ?>
1237
1238         <?php if ( !$bulk ) echo $authors_dropdown;
1239         endif; // post_type_supports author
1240
1241         if ( !$bulk && $can_publish ) :
1242         ?>
1243
1244                         <div class="inline-edit-group">
1245                                 <label class="alignleft">
1246                                         <span class="title"><?php _e( 'Password' ); ?></span>
1247                                         <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1248                                 </label>
1249
1250                                 <em class="alignleft inline-edit-or">
1251                                         <?php
1252                                         /* translators: Between password field and private checkbox on post quick edit interface */
1253                                         _e( '&ndash;OR&ndash;' );
1254                                         ?>
1255                                 </em>
1256                                 <label class="alignleft inline-edit-private">
1257                                         <input type="checkbox" name="keep_private" value="private" />
1258                                         <span class="checkbox-title"><?php _e( 'Private' ); ?></span>
1259                                 </label>
1260                         </div>
1261
1262         <?php endif; ?>
1263
1264                 </div></fieldset>
1265
1266         <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
1267
1268                 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1269
1270         <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
1271
1272                         <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1273                         <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
1274                         <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
1275                                 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
1276                         </ul>
1277
1278         <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
1279
1280                 </div></fieldset>
1281
1282         <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
1283
1284                 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1285
1286         <?php
1287                 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1288                         echo $authors_dropdown;
1289
1290                 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1291
1292                         if ( $post_type_object->hierarchical ) :
1293                 ?>
1294                         <label>
1295                                 <span class="title"><?php _e( 'Parent' ); ?></span>
1296         <?php
1297                 $dropdown_args = array(
1298                         'post_type'         => $post_type_object->name,
1299                         'selected'          => $post->post_parent,
1300                         'name'              => 'post_parent',
1301                         'show_option_none'  => __( 'Main Page (no parent)' ),
1302                         'option_none_value' => 0,
1303                         'sort_column'       => 'menu_order, post_title',
1304                 );
1305
1306                 if ( $bulk )
1307                         $dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
1308
1309                 /**
1310                  * Filter the arguments used to generate the Quick Edit page-parent drop-down.
1311                  *
1312                  * @since 2.7.0
1313                  *
1314                  * @see wp_dropdown_pages()
1315                  *
1316                  * @param array $dropdown_args An array of arguments.
1317                  */
1318                 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
1319
1320                 wp_dropdown_pages( $dropdown_args );
1321         ?>
1322                         </label>
1323
1324         <?php
1325                         endif; // hierarchical
1326
1327                         if ( !$bulk ) : ?>
1328
1329                         <label>
1330                                 <span class="title"><?php _e( 'Order' ); ?></span>
1331                                 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1332                         </label>
1333
1334         <?php   endif; // !$bulk
1335
1336                         if ( 'page' == $screen->post_type ) :
1337         ?>
1338
1339                         <label>
1340                                 <span class="title"><?php _e( 'Template' ); ?></span>
1341                                 <select name="page_template">
1342         <?php   if ( $bulk ) : ?>
1343                                         <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1344         <?php   endif; // $bulk ?>
1345                                 <?php
1346                                         /** This filter is documented in wp-admin/includes/meta-boxes.php */
1347                                         $default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'quick-edit' );
1348                                 ?>
1349                                         <option value="default"><?php echo esc_html( $default_title ); ?></option>
1350                                         <?php page_template_dropdown() ?>
1351                                 </select>
1352                         </label>
1353
1354         <?php
1355                         endif; // page post_type
1356                 endif; // page-attributes
1357         ?>
1358
1359         <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
1360
1361         <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
1362                 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
1363                         <label class="inline-edit-tags">
1364                                 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1365                                 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
1366                         </label>
1367                 <?php endif; ?>
1368
1369         <?php endforeach; //$flat_taxonomies as $taxonomy ?>
1370
1371         <?php endif; // count( $flat_taxonomies ) && !$bulk  ?>
1372
1373         <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
1374                 if ( $bulk ) : ?>
1375
1376                         <div class="inline-edit-group">
1377                 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1378                         <label class="alignleft">
1379                                 <span class="title"><?php _e( 'Comments' ); ?></span>
1380                                 <select name="comment_status">
1381                                         <option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1382                                         <option value="open"><?php _e( 'Allow' ); ?></option>
1383                                         <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1384                                 </select>
1385                         </label>
1386                 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1387                         <label class="alignright">
1388                                 <span class="title"><?php _e( 'Pings' ); ?></span>
1389                                 <select name="ping_status">
1390                                         <option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1391                                         <option value="open"><?php _e( 'Allow' ); ?></option>
1392                                         <option value="closed"><?php _e( 'Do not allow' ); ?></option>
1393                                 </select>
1394                         </label>
1395                 <?php endif; ?>
1396                         </div>
1397
1398         <?php else : // $bulk ?>
1399
1400                         <div class="inline-edit-group">
1401                         <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1402                                 <label class="alignleft">
1403                                         <input type="checkbox" name="comment_status" value="open" />
1404                                         <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1405                                 </label>
1406                         <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1407                                 <label class="alignleft">
1408                                         <input type="checkbox" name="ping_status" value="open" />
1409                                         <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1410                                 </label>
1411                         <?php endif; ?>
1412                         </div>
1413
1414         <?php endif; // $bulk
1415         endif; // post_type_supports comments or pings ?>
1416
1417                         <div class="inline-edit-group">
1418                                 <label class="inline-edit-status alignleft">
1419                                         <span class="title"><?php _e( 'Status' ); ?></span>
1420                                         <select name="_status">
1421         <?php if ( $bulk ) : ?>
1422                                                 <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1423         <?php endif; // $bulk ?>
1424                                         <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1425                                                 <option value="publish"><?php _e( 'Published' ); ?></option>
1426                                                 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1427         <?php if ( $bulk ) : ?>
1428                                                 <option value="private"><?php _e( 'Private' ) ?></option>
1429         <?php endif; // $bulk ?>
1430                                         <?php endif; ?>
1431                                                 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1432                                                 <option value="draft"><?php _e( 'Draft' ); ?></option>
1433                                         </select>
1434                                 </label>
1435
1436         <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1437
1438         <?php   if ( $bulk ) : ?>
1439
1440                                 <label class="alignright">
1441                                         <span class="title"><?php _e( 'Sticky' ); ?></span>
1442                                         <select name="sticky">
1443                                                 <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1444                                                 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1445                                                 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1446                                         </select>
1447                                 </label>
1448
1449         <?php   else : // $bulk ?>
1450
1451                                 <label class="alignleft">
1452                                         <input type="checkbox" name="sticky" value="sticky" />
1453                                         <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1454                                 </label>
1455
1456         <?php   endif; // $bulk ?>
1457
1458         <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1459
1460                         </div>
1461
1462         <?php
1463
1464         if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1465                 $post_formats = get_theme_support( 'post-formats' );
1466
1467                 ?>
1468                 <label class="alignleft">
1469                 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1470                 <select name="post_format">
1471                         <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1472                         <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
1473                         <?php
1474
1475                         foreach ( $post_formats[0] as $format ) {
1476                                 ?>
1477                                 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
1478                                 <?php
1479                         }
1480
1481                         ?>
1482                 </select></label>
1483         <?php
1484
1485         }
1486
1487         ?>
1488
1489                 </div></fieldset>
1490
1491         <?php
1492                 list( $columns ) = $this->get_column_info();
1493
1494                 foreach ( $columns as $column_name => $column_display_name ) {
1495                         if ( isset( $core_columns[$column_name] ) )
1496                                 continue;
1497
1498                         if ( $bulk ) {
1499
1500                                 /**
1501                                  * Fires once for each column in Bulk Edit mode.
1502                                  *
1503                                  * @since 2.7.0
1504                                  *
1505                                  * @param string  $column_name Name of the column to edit.
1506                                  * @param WP_Post $post_type   The post type slug.
1507                                  */
1508                                 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
1509                         } else {
1510
1511                                 /**
1512                                  * Fires once for each column in Quick Edit mode.
1513                                  *
1514                                  * @since 2.7.0
1515                                  *
1516                                  * @param string  $column_name Name of the column to edit.
1517                                  * @param WP_Post $post_type   The post type slug.
1518                                  */
1519                                 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type );
1520                         }
1521
1522                 }
1523         ?>
1524                 <p class="submit inline-edit-save">
1525                         <button type="button" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></button>
1526                         <?php if ( ! $bulk ) {
1527                                 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1528                                 ?>
1529                                 <button type="button" class="button-primary save alignright"><?php _e( 'Update' ); ?></button>
1530                                 <span class="spinner"></span>
1531                         <?php } else {
1532                                 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false );
1533                         } ?>
1534                         <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1535                         <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1536                         <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1537                                 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1538                         <?php } ?>
1539                         <span class="error" style="display:none"></span>
1540                         <br class="clear" />
1541                 </p>
1542                 </td></tr>
1543         <?php
1544                 $bulk++;
1545                 }
1546 ?>
1547                 </tbody></table></form>
1548 <?php
1549         }
1550 }