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