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