Make WordPress Core

Ticket #29881: wp-posts-list-table.diff

File wp-posts-list-table.diff, 26.9 KB (added by joehoyle, 10 years ago)
  • src/wp-admin/includes/class-wp-posts-list-table.php

     
    4646        private $sticky_posts_count = 0;
    4747
    4848        /**
     49         * Stores the current row's level.
     50         *
     51         * As WP_List_Table doesn't have a concept of hierarchical rows, we have
     52         * to store the row level so it can be accessed by the column_$column_name methods.
     53         * @var integer
     54         */
     55        private $row_level = 0;
     56
     57        /**
    4958         * Constructor.
    5059         *
    5160         * @since 3.1.0
     
    540549                unset( $children_pages[$parent] ); //required in order to keep track of orphans
    541550        }
    542551
    543         public function single_row( $post, $level = 0 ) {
     552        /**
     553         * Display the Checkbox column, only if the user can edit the post
     554         *
     555         * @todo Check the classname check-column / column-check
     556         *
     557         * @param  WP_Post $post
     558         * @return null
     559         */
     560        public function column_cb( $post ) {
     561
     562                if ( ! current_user_can( 'edit_post', $post->ID ) ) {
     563                        return '';
     564                }
     565
     566                ?>
     567                <label class="screen-reader-text" for="cb-select-<?php echo esc_attr( $post->ID ); ?>"><?php printf( __( 'Select %s' ), _draft_or_post_title( $post ) ); ?></label>
     568                <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php echo esc_attr( $post->ID ); ?>" />
     569                <div class="locked-indicator"></div>
     570                <?php
     571        }
     572
     573        /**
     574         * Display the title column for a post
     575         *
     576         * @todo classes on column
     577         *
     578         * @param  WP_Post $post
     579         * @return null
     580         */
     581        public function column_title( $post ) {
     582
    544583                global $mode;
    545                 static $alternate;
    546584
    547                 $global_post = get_post();
    548                 $GLOBALS['post'] = $post;
    549                 setup_postdata( $post );
    550 
     585                $level = $this->row_level;
    551586                $edit_link = get_edit_post_link( $post->ID );
    552587                $title = _draft_or_post_title();
    553588                $post_type_object = get_post_type_object( $post->post_type );
    554589                $can_edit_post = current_user_can( 'edit_post', $post->ID );
     590                $lock_holder = wp_check_post_lock( $post->ID );
    555591
    556                 $alternate = 'alternate' == $alternate ? '' : 'alternate';
    557                 $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
     592                if ( $this->hierarchical_display ) {
     593                        if ( 0 == $level && (int) $post->post_parent > 0 ) {
     594                                // Sent level 0 by accident, by default, or because we don't know the actual level.
     595                                $find_main_page = (int) $post->post_parent;
     596                                while ( $find_main_page > 0 ) {
     597                                        $parent = get_post( $find_main_page );
    558598
    559                 $lock_holder = wp_check_post_lock( $post->ID );
    560                 if ( $lock_holder ) {
    561                         $classes .= ' wp-locked';
    562                         $lock_holder = get_userdata( $lock_holder );
     599                                        if ( is_null( $parent ) )
     600                                                break;
     601
     602                                        $level++;
     603                                        $find_main_page = (int) $parent->post_parent;
     604
     605                                        if ( !isset( $parent_name ) ) {
     606                                                /** This filter is documented in wp-includes/post-template.php */
     607                                                $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
     608                                        }
     609                                }
     610                        }
    563611                }
    564612
    565                 if ( $post->post_parent ) {
    566                     $count = count( get_post_ancestors( $post->ID ) );
    567                     $classes .= ' level-'. $count;
     613                $pad = str_repeat( '&#8212; ', $level );
     614
     615                if ( $format = get_post_format( $post->ID ) ) {
     616                        $label = get_post_format_string( $format );
     617
     618                        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> ";
     619                }
     620
     621                if ( $can_edit_post && $post->post_status != 'trash' ) {
     622                        echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . $pad . $title . '</a>';
    568623                } else {
    569                     $classes .= ' level-0';
     624                        echo $pad . $title;
    570625                }
    571         ?>
    572                 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
    573         <?php
     626                _post_states( $post );
    574627
    575                 list( $columns, $hidden ) = $this->get_column_info();
     628                if ( isset( $parent_name ) )
     629                        echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
    576630
    577                 foreach ( $columns as $column_name => $column_display_name ) {
    578                         $class = "class=\"$column_name column-$column_name\"";
     631                echo "</strong>\n";
    579632
    580                         $style = '';
    581                         if ( in_array( $column_name, $hidden ) )
    582                                 $style = ' style="display:none;"';
     633                if ( $can_edit_post && $post->post_status != 'trash' ) {
     634                        if ( $lock_holder ) {
     635                                $locked_avatar = get_avatar( $lock_holder->ID, 18 );
     636                                $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
     637                        } else {
     638                                $locked_avatar = $locked_text = '';
     639                        }
    583640
    584                         $attributes = "$class$style";
     641                        echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
     642                }
    585643
    586                         switch ( $column_name ) {
     644                if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) {
     645                        the_excerpt();
     646                }
    587647
    588                         case 'cb':
    589                         ?>
    590                         <th scope="row" class="check-column">
    591                                 <?php
     648                $actions = array();
     649                if ( $can_edit_post && 'trash' != $post->post_status ) {
     650                        $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
     651                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
     652                }
     653                if ( current_user_can( 'delete_post', $post->ID ) ) {
     654                        if ( 'trash' == $post->post_status )
     655                                $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>";
     656                        elseif ( EMPTY_TRASH_DAYS )
     657                                $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
     658                        if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
     659                                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
     660                }
     661                if ( $post_type_object->public ) {
     662                        if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
    592663                                if ( $can_edit_post ) {
    593 
    594                                 ?>
    595                                 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
    596                                 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
    597                                 <div class="locked-indicator"></div>
    598                                 <?php
     664                                        $preview_link = set_url_scheme( get_permalink( $post->ID ) );
     665                                        /** This filter is documented in wp-admin/includes/meta-boxes.php */
     666                                        $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
     667                                        $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
    599668                                }
    600                                 ?>
    601                         </th>
    602                         <?php
    603                         break;
     669                        } elseif ( 'trash' != $post->post_status ) {
     670                                $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
     671                        }
     672                }
    604673
    605                         case 'title':
    606                                 $attributes = 'class="post-title page-title column-title"' . $style;
    607                                 if ( $this->hierarchical_display ) {
    608                                         if ( 0 == $level && (int) $post->post_parent > 0 ) {
    609                                                 // Sent level 0 by accident, by default, or because we don't know the actual level.
    610                                                 $find_main_page = (int) $post->post_parent;
    611                                                 while ( $find_main_page > 0 ) {
    612                                                         $parent = get_post( $find_main_page );
     674                if ( is_post_type_hierarchical( $post->post_type ) ) {
    613675
    614                                                         if ( is_null( $parent ) )
    615                                                                 break;
     676                        /**
     677                         * Filter the array of row action links on the Pages list table.
     678                         *
     679                         * The filter is evaluated only for hierarchical post types.
     680                         *
     681                         * @since 2.8.0
     682                         *
     683                         * @param array   $actions An array of row action links. Defaults are
     684                         *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
     685                         *                         'Delete Permanently', 'Preview', and 'View'.
     686                         * @param WP_Post $post    The post object.
     687                         */
     688                        $actions = apply_filters( 'page_row_actions', $actions, $post );
     689                } else {
    616690
    617                                                         $level++;
    618                                                         $find_main_page = (int) $parent->post_parent;
     691                        /**
     692                         * Filter the array of row action links on the Posts list table.
     693                         *
     694                         * The filter is evaluated only for non-hierarchical post types.
     695                         *
     696                         * @since 2.8.0
     697                         *
     698                         * @param array   $actions An array of row action links. Defaults are
     699                         *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
     700                         *                         'Delete Permanently', 'Preview', and 'View'.
     701                         * @param WP_Post $post    The post object.
     702                         */
     703                        $actions = apply_filters( 'post_row_actions', $actions, $post );
     704                }
    619705
    620                                                         if ( !isset( $parent_name ) ) {
    621                                                                 /** This filter is documented in wp-includes/post-template.php */
    622                                                                 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
    623                                                         }
    624                                                 }
    625                                         }
    626                                 }
     706                echo $this->row_actions( $actions );
    627707
    628                                 $pad = str_repeat( '&#8212; ', $level );
    629                                 echo "<td $attributes><strong>";
     708                get_inline_data( $post );
     709        }
    630710
    631                                 if ( $format = get_post_format( $post->ID ) ) {
    632                                         $label = get_post_format_string( $format );
     711        /**
     712         * Display the post date column for a post
     713         *
     714         * @param  WP_Post $post
     715         * @return null
     716         */
     717        public function column_date( $post ) {
    633718
    634                                         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> ";
    635                                 }
     719                global $mode;
     720                $column_name = 'date';
    636721
    637                                 if ( $can_edit_post && $post->post_status != 'trash' ) {
    638                                         echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . $pad . $title . '</a>';
    639                                 } else {
    640                                         echo $pad . $title;
    641                                 }
    642                                 _post_states( $post );
     722                if ( '0000-00-00 00:00:00' == $post->post_date ) {
     723                        $t_time = $h_time = __( 'Unpublished' );
     724                        $time_diff = 0;
     725                } else {
     726                        $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
     727                        $m_time = $post->post_date;
     728                        $time = get_post_time( 'G', true, $post );
    643729
    644                                 if ( isset( $parent_name ) )
    645                                         echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
     730                        $time_diff = time() - $time;
    646731
    647                                 echo "</strong>\n";
     732                        if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
     733                                $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
     734                        else
     735                                $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
     736                }
    648737
    649                                 if ( $can_edit_post && $post->post_status != 'trash' ) {
    650                                         if ( $lock_holder ) {
    651                                                 $locked_avatar = get_avatar( $lock_holder->ID, 18 );
    652                                                 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
    653                                         } else {
    654                                                 $locked_avatar = $locked_text = '';
    655                                         }
     738                if ( 'excerpt' == $mode ) {
    656739
    657                                         echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
    658                                 }
     740                        /**
     741                         * Filter the published time of the post.
     742                         *
     743                         * If $mode equals 'excerpt', the published time and date are both displayed.
     744                         * If $mode equals 'list' (default), the publish date is displayed, with the
     745                         * time and date together available as an abbreviation definition.
     746                         *
     747                         * @since 2.5.1
     748                         *
     749                         * @param array   $t_time      The published time.
     750                         * @param WP_Post $post        Post object.
     751                         * @param string  $column_name The column name.
     752                         * @param string  $mode        The list display mode ('excerpt' or 'list').
     753                         */
     754                        echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
     755                } else {
    659756
    660                                 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
    661                                                 the_excerpt();
     757                        /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
     758                        echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
     759                }
     760                echo '<br />';
     761                if ( 'publish' == $post->post_status ) {
     762                        _e( 'Published' );
     763                } elseif ( 'future' == $post->post_status ) {
     764                        if ( $time_diff > 0 )
     765                                echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
     766                        else
     767                                _e( 'Scheduled' );
     768                } else {
     769                        _e( 'Last Modified' );
     770                }
     771        }
    662772
    663                                 $actions = array();
    664                                 if ( $can_edit_post && 'trash' != $post->post_status ) {
    665                                         $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
    666                                         $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    667                                 }
    668                                 if ( current_user_can( 'delete_post', $post->ID ) ) {
    669                                         if ( 'trash' == $post->post_status )
    670                                                 $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>";
    671                                         elseif ( EMPTY_TRASH_DAYS )
    672                                                 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
    673                                         if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
    674                                                 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
    675                                 }
    676                                 if ( $post_type_object->public ) {
    677                                         if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
    678                                                 if ( $can_edit_post ) {
    679                                                         $preview_link = set_url_scheme( get_permalink( $post->ID ) );
    680                                                         /** This filter is documented in wp-admin/includes/meta-boxes.php */
    681                                                         $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
    682                                                         $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
    683                                                 }
    684                                         } elseif ( 'trash' != $post->post_status ) {
    685                                                 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
    686                                         }
    687                                 }
     773        /**
     774         * Display the comment count column for a post
     775         *
     776         * @param  WP_Post $post
     777         * @return null
     778         */
     779        public function column_comments( $post ) {
    688780
    689                                 if ( is_post_type_hierarchical( $post->post_type ) ) {
     781                $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
    690782
    691                                         /**
    692                                          * Filter the array of row action links on the Pages list table.
    693                                          *
    694                                          * The filter is evaluated only for hierarchical post types.
    695                                          *
    696                                          * @since 2.8.0
    697                                          *
    698                                          * @param array   $actions An array of row action links. Defaults are
    699                                          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
    700                                          *                         'Delete Permanently', 'Preview', and 'View'.
    701                                          * @param WP_Post $post    The post object.
    702                                          */
    703                                         $actions = apply_filters( 'page_row_actions', $actions, $post );
    704                                 } else {
     783                ?>
     784                <div class="post-com-count-wrapper">
     785                        <?php $this->comments_bubble( $post->ID, $pending_comments ); ?>
     786                </div>
     787                <?php
     788        }
    705789
    706                                         /**
    707                                          * Filter the array of row action links on the Posts list table.
    708                                         *
    709                                          * The filter is evaluated only for non-hierarchical post types.
    710                                          *
    711                                          * @since 2.8.0
    712                                          *
    713                                          * @param array   $actions An array of row action links. Defaults are
    714                                          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
    715                                          *                         'Delete Permanently', 'Preview', and 'View'.
    716                                          * @param WP_Post $post    The post object.
    717                                          */
    718                                         $actions = apply_filters( 'post_row_actions', $actions, $post );
    719                                 }
     790        /**
     791         * Display the post author column for the post
     792        *
     793         * @todo get_the_author needs global authordata
     794         *
     795         * @param  WP_Post $post
     796         * @return null
     797         */
     798        public function column_author( $post ) {
     799                printf( '<a href="%s">%s</a>',
     800                        esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => $post->post_author ), 'edit.php' ) ),
     801                        get_the_author()
     802                );
     803        }
    720804
    721                                 echo $this->row_actions( $actions );
     805        /**
     806         * Display the post tags column for the post
     807         *
     808         * @param  WP_Post $post
     809         * @return null
     810         */
     811        public function column_tags( $post ) {
     812                $this->column_taxonomy( $post, 'post_tag' );
     813        }
    722814
    723                                 get_inline_data( $post );
    724                                 echo '</td>';
    725                         break;
     815        /**
     816         * Display the post categories column for the post
     817         *
     818         * @param  WP_Post $post
     819         * @return null
     820         */
     821        public function column_categories( $post ) {
     822                $this->column_taxonomy( $post, 'category' );
     823        }
    726824
    727                         case 'date':
    728                                 if ( '0000-00-00 00:00:00' == $post->post_date ) {
    729                                         $t_time = $h_time = __( 'Unpublished' );
    730                                         $time_diff = 0;
    731                                 } else {
    732                                         $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
    733                                         $m_time = $post->post_date;
    734                                         $time = get_post_time( 'G', true, $post );
     825        /**
     826         * Display a taxonomy's column for the post
     827         *
     828         * @param  WP_Post $post     
     829         * @param  string  $taxonomy
     830         * @return null
     831         */
     832        public function column_taxonomy( $post, $taxonomy ) {
    735833
    736                                         $time_diff = time() - $time;
     834                $taxonomy_object = get_taxonomy( $taxonomy );
    737835
    738                                         if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
    739                                                 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
    740                                         else
    741                                                 $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
     836                if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
     837                        $out = array();
     838                        foreach ( $terms as $t ) {
     839                                $posts_in_term_qv = array();
     840                                if ( 'post' != $post->post_type )
     841                                        $posts_in_term_qv['post_type'] = $post->post_type;
     842                                if ( $taxonomy_object->query_var ) {
     843                                        $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
     844                                } else {
     845                                        $posts_in_term_qv['taxonomy'] = $taxonomy;
     846                                        $posts_in_term_qv['term'] = $t->slug;
    742847                                }
    743848
    744                                 echo '<td ' . $attributes . '>';
    745                                 if ( 'excerpt' == $mode ) {
     849                                $out[] = sprintf( '<a href="%s">%s</a>',
     850                                        esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
     851                                        esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
     852                                );
     853                        }
     854                        /* translators: used between list items, there is a space after the comma */
     855                        echo join( __( ', ' ), $out );
     856                } else {
     857                        echo '&#8212;';
     858                }
     859        }
    746860
    747                                         /**
    748                                          * Filter the published time of the post.
    749                                          *
    750                                          * If $mode equals 'excerpt', the published time and date are both displayed.
    751                                          * If $mode equals 'list' (default), the publish date is displayed, with the
    752                                          * time and date together available as an abbreviation definition.
    753                                          *
    754                                          * @since 2.5.1
    755                                          *
    756                                          * @param array   $t_time      The published time.
    757                                          * @param WP_Post $post        Post object.
    758                                          * @param string  $column_name The column name.
    759                                          * @param string  $mode        The list display mode ('excerpt' or 'list').
    760                                          */
    761                                         echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
    762                                 } else {
     861        /**
     862         * Display a custom column for the post
     863         *
     864         * In the event of a taxonomy column in the form of "taxonomy-$taxonomy", column_taxonomy() is called.
     865         *
     866         * @param  WP_Post $post
     867         * @param  string  $column_name
     868         * @return null
     869         */
     870        public function column_default( $post, $column_name ) {
    763871
    764                                         /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
    765                                         echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
    766                                 }
    767                                 echo '<br />';
    768                                 if ( 'publish' == $post->post_status ) {
    769                                         _e( 'Published' );
    770                                 } elseif ( 'future' == $post->post_status ) {
    771                                         if ( $time_diff > 0 )
    772                                                 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
    773                                         else
    774                                                 _e( 'Scheduled' );
    775                                 } else {
    776                                         _e( 'Last Modified' );
    777                                 }
    778                                 echo '</td>';
    779                         break;
     872                if ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
     873                        return $this->column_taxonomy( $post, substr( $column_name, 9 ) );
     874                }
    780875
    781                         case 'comments':
    782                         ?>
    783                         <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
    784                         <?php
    785                                 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
     876                if ( is_post_type_hierarchical( $post->post_type ) ) {
    786877
    787                                 $this->comments_bubble( $post->ID, $pending_comments );
    788                         ?>
    789                         </div></td>
    790                         <?php
    791                         break;
     878                        /**
     879                         * Fires in each custom column on the Posts list table.
     880                         *
     881                         * This hook only fires if the current post type is hierarchical,
     882                         * such as pages.
     883                         *
     884                         * @since 2.5.0
     885                         *
     886                         * @param string $column_name The name of the column to display.
     887                         * @param int    $post_id     The current post ID.
     888                         */
     889                        do_action( 'manage_pages_custom_column', $column_name, $post->ID );
     890                } else {
    792891
    793                         case 'author':
    794                         ?>
    795                         <td <?php echo $attributes ?>><?php
    796                                 printf( '<a href="%s">%s</a>',
    797                                         esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
    798                                         get_the_author()
    799                                 );
    800                         ?></td>
    801                         <?php
    802                         break;
     892                        /**
     893                         * Fires in each custom column in the Posts list table.
     894                         *
     895                         * This hook only fires if the current post type is non-hierarchical,
     896                         * such as posts.
     897                         *
     898                         * @since 1.5.0
     899                         *
     900                         * @param string $column_name The name of the column to display.
     901                         * @param int    $post_id     The current post ID.
     902                         */
     903                        do_action( 'manage_posts_custom_column', $column_name, $post->ID );
     904                }
    803905
    804                         default:
    805                                 if ( 'categories' == $column_name )
    806                                         $taxonomy = 'category';
    807                                 elseif ( 'tags' == $column_name )
    808                                         $taxonomy = 'post_tag';
    809                                 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
    810                                         $taxonomy = substr( $column_name, 9 );
    811                                 else
    812                                         $taxonomy = false;
     906                /**
     907                 * Fires for each custom column of a specific post type in the Posts list table.
     908                 *
     909                 * The dynamic portion of the hook name, $post->post_type, refers to the post type.
     910                 *
     911                 * @since 3.1.0
     912                 *
     913                 * @param string $column_name The name of the column to display.
     914                 * @param int    $post_id     The current post ID.
     915                 */
     916                do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
     917        }
    813918
    814                                 if ( $taxonomy ) {
    815                                         $taxonomy_object = get_taxonomy( $taxonomy );
    816                                         echo '<td ' . $attributes . '>';
    817                                         if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
    818                                                 $out = array();
    819                                                 foreach ( $terms as $t ) {
    820                                                         $posts_in_term_qv = array();
    821                                                         if ( 'post' != $post->post_type )
    822                                                                 $posts_in_term_qv['post_type'] = $post->post_type;
    823                                                         if ( $taxonomy_object->query_var ) {
    824                                                                 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
    825                                                         } else {
    826                                                                 $posts_in_term_qv['taxonomy'] = $taxonomy;
    827                                                                 $posts_in_term_qv['term'] = $t->slug;
    828                                                         }
     919        public function single_row( $post, $level = 0 ) {
     920                global $mode;
     921                static $alternate;
    829922
    830                                                         $out[] = sprintf( '<a href="%s">%s</a>',
    831                                                                 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
    832                                                                 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
    833                                                         );
    834                                                 }
    835                                                 /* translators: used between list items, there is a space after the comma */
    836                                                 echo join( __( ', ' ), $out );
    837                                         } else {
    838                                                 echo '&#8212;';
    839                                         }
    840                                         echo '</td>';
    841                                         break;
    842                                 }
    843                         ?>
    844                         <td <?php echo $attributes ?>><?php
    845                                 if ( is_post_type_hierarchical( $post->post_type ) ) {
     923                $this->row_level = $level;
    846924
    847                                         /**
    848                                          * Fires in each custom column on the Posts list table.
    849                                          *
    850                                          * This hook only fires if the current post type is hierarchical,
    851                                          * such as pages.
    852                                          *
    853                                          * @since 2.5.0
    854                                          *
    855                                          * @param string $column_name The name of the column to display.
    856                                          * @param int    $post_id     The current post ID.
    857                                          */
    858                                         do_action( 'manage_pages_custom_column', $column_name, $post->ID );
    859                                 } else {
     925                $global_post = get_post();
     926                $GLOBALS['post'] = $post;
     927                setup_postdata( $post );
    860928
    861                                         /**
    862                                          * Fires in each custom column in the Posts list table.
    863                                          *
    864                                          * This hook only fires if the current post type is non-hierarchical,
    865                                          * such as posts.
    866                                          *
    867                                          * @since 1.5.0
    868                                          *
    869                                          * @param string $column_name The name of the column to display.
    870                                          * @param int    $post_id     The current post ID.
    871                                          */
    872                                         do_action( 'manage_posts_custom_column', $column_name, $post->ID );
    873                                 }
     929                $edit_link = get_edit_post_link( $post->ID );
     930                $title = _draft_or_post_title();
     931                $post_type_object = get_post_type_object( $post->post_type );
     932                $can_edit_post = current_user_can( 'edit_post', $post->ID );
    874933
    875                                 /**
    876                                  * Fires for each custom column of a specific post type in the Posts list table.
    877                                  *
    878                                  * The dynamic portion of the hook name, $post->post_type, refers to the post type.
    879                                  *
    880                                  * @since 3.1.0
    881                                  *
    882                                  * @param string $column_name The name of the column to display.
    883                                  * @param int    $post_id     The current post ID.
    884                                  */
    885                                 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
    886                         ?></td>
    887                         <?php
    888                         break;
    889                         }
     934                $alternate = 'alternate' == $alternate ? '' : 'alternate';
     935                $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
     936
     937                $lock_holder = wp_check_post_lock( $post->ID );
     938                if ( $lock_holder ) {
     939                        $classes .= ' wp-locked';
     940                        $lock_holder = get_userdata( $lock_holder );
    890941                }
    891         ?>
     942
     943                if ( $post->post_parent ) {
     944                    $count = count( get_post_ancestors( $post->ID ) );
     945                    $classes .= ' level-'. $count;
     946                } else {
     947                    $classes .= ' level-0';
     948                }
     949
     950                ?>
     951                <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
     952
     953                        <?php $this->single_row_columns( $post ); ?>
    892954                </tr>
    893955        <?php
     956
     957                list( $columns, $hidden ) = $this->get_column_info();
     958
     959                foreach ( $columns as $column_name => $column_display_name ) {
     960                        $class = "class=\"$column_name column-$column_name\"";
     961                }
     962                       
    894963                $GLOBALS['post'] = $global_post;
    895964        }
    896965