<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[32740] trunk/src/wp-admin/includes/class-wp-posts-list-table.php: Override `->single_row_columns()` in `WP_Posts_List_Table`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/32740">32740</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/32740","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-06-12 20:17:59 +0000 (Fri, 12 Jun 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Override `->single_row_columns()` in `WP_Posts_List_Table`.
Break apart the giant `switch` statement in `->single_row()` into `column_{$column_name}` methods.
To maintain the `->single_row_columns( $item )` interface, add a property, `$current_level`, to allow access to `$level`.
This list table class is now easier to subclass.
Props joehoyle, wonderboymusic.
See <a href="https://core.trac.wordpress.org/ticket/29881">#29881</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswppostslisttablephp">trunk/src/wp-admin/includes/class-wp-posts-list-table.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswppostslisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-posts-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-posts-list-table.php 2015-06-12 18:54:56 UTC (rev 32739)
+++ trunk/src/wp-admin/includes/class-wp-posts-list-table.php 2015-06-12 20:17:59 UTC (rev 32740)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,6 +48,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> private $is_trash;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.3.0
+ * @var int
+ */
+ protected $current_level = 0;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -671,297 +677,357 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global string $mode
- * @global WP_Post $post
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.3.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|WP_Post $post
- * @param int $level
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Post $post
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function single_row( $post, $level = 0 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function column_cb( $post ) {
+ $can_edit_post = current_user_can( 'edit_post', $post->ID );
+ $title = _draft_or_post_title();
+ ?>
+ <th scope="row" class="check-column">
+ <?php if ( $can_edit_post ) { ?>
+ <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
+ <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
+ <div class="locked-indicator"></div>
+ <?php } ?>
+ </th>
+ <?php
+ }
+
+ /**
+ * @since 4.3.0
+ *
+ * @global string $mode
+ *
+ * @param WP_Post $post
+ */
+ public function column_title( $post ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $mode;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $global_post = get_post();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->hierarchical_display ) {
+ if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) {
+ // Sent level 0 by accident, by default, or because we don't know the actual level.
+ $find_main_page = (int) $post->post_parent;
+ while ( $find_main_page > 0 ) {
+ $parent = get_post( $find_main_page );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_null( $parent ) ) {
+ break;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $GLOBALS['post'] = $post;
- setup_postdata( $post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->current_level++;
+ $find_main_page = (int) $parent->post_parent;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $edit_link = get_edit_post_link( $post->ID );
- $title = _draft_or_post_title();
- $post_type_object = get_post_type_object( $post->post_type );
- $can_edit_post = current_user_can( 'edit_post', $post->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! isset( $parent_name ) ) {
+ /** This filter is documented in wp-includes/post-template.php */
+ $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
+ }
+ }
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $pad = str_repeat( '— ', $this->current_level );
+ echo "<strong>";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $lock_holder = wp_check_post_lock( $post->ID );
- if ( $lock_holder ) {
- $classes .= ' wp-locked';
- $lock_holder = get_userdata( $lock_holder );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $format = get_post_format( $post->ID );
+ if ( $format ) {
+ $label = get_post_format_string( $format );
+
+ 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> ";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $post->post_parent ) {
- $count = count( get_post_ancestors( $post->ID ) );
- $classes .= ' level-'. $count;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $can_edit_post = current_user_can( 'edit_post', $post->ID );
+ $title = _draft_or_post_title();
+
+ if ( $can_edit_post && $post->post_status != 'trash' ) {
+ $edit_link = get_edit_post_link( $post->ID );
+ echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $classes .= ' level-0';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo $pad . $title;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ?>
- <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
- <?php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _post_states( $post );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $parent_name ) ) {
+ $post_type_object = get_post_type_object( $post->post_type );
+ echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
+ }
+ echo "</strong>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $columns as $column_name => $column_display_name ) {
- $classes = "$column_name column-$column_name";
- if ( $primary === $column_name ) {
- $classes .= ' has-row-actions column-primary';
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $can_edit_post && $post->post_status != 'trash' ) {
+ $lock_holder = wp_check_post_lock( $post->ID );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'title' === $column_name ) {
- $classes .= ' page-title'; // Special addition for title column
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $lock_holder ) {
+ $lock_holder = get_userdata( $lock_holder );
+ $locked_avatar = get_avatar( $lock_holder->ID, 18 );
+ $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
+ } else {
+ $locked_avatar = $locked_text = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( in_array( $column_name, $hidden ) ) {
- $classes .= ' hidden';
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attributes = "class='$classes'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) {
+ the_excerpt();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'cb' === $column_name ) {
- ?>
- <th scope="row" class="check-column">
- <?php if ( $can_edit_post ) { ?>
- <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
- <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
- <div class="locked-indicator"></div>
- <?php } ?>
- </th>
- <?php
- } else {
- echo "<td $attributes>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_inline_data( $post );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch ( $column_name ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @since 4.3.0
+ *
+ * @global string $mode
+ *
+ * @param WP_Post $post
+ */
+ public function column_date( $post ) {
+ global $mode;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- case 'title':
- if ( $this->hierarchical_display ) {
- if ( 0 == $level && (int) $post->post_parent > 0 ) {
- // Sent level 0 by accident, by default, or because we don't know the actual level.
- $find_main_page = (int) $post->post_parent;
- while ( $find_main_page > 0 ) {
- $parent = get_post( $find_main_page );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( '0000-00-00 00:00:00' == $post->post_date ) {
+ $t_time = $h_time = __( 'Unpublished' );
+ $time_diff = 0;
+ } else {
+ $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
+ $m_time = $post->post_date;
+ $time = get_post_time( 'G', true, $post );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_null( $parent ) )
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $time_diff = time() - $time;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $level++;
- $find_main_page = (int) $parent->post_parent;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
+ $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
+ } else {
+ $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !isset( $parent_name ) ) {
- /** This filter is documented in wp-includes/post-template.php */
- $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
- }
- }
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'excerpt' == $mode ) {
+ /**
+ * Filter the published time of the post.
+ *
+ * If $mode equals 'excerpt', the published time and date are both displayed.
+ * If $mode equals 'list' (default), the publish date is displayed, with the
+ * time and date together available as an abbreviation definition.
+ *
+ * @since 2.5.1
+ *
+ * @param array $t_time The published time.
+ * @param WP_Post $post Post object.
+ * @param string $column_name The column name.
+ * @param string $mode The list display mode ('excerpt' or 'list').
+ */
+ echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $pad = str_repeat( '— ', $level );
- echo "<strong>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
+ echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>';
+ }
+ echo '<br />';
+ if ( 'publish' == $post->post_status ) {
+ _e( 'Published' );
+ } elseif ( 'future' == $post->post_status ) {
+ if ( $time_diff > 0 ) {
+ echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
+ } else {
+ _e( 'Scheduled' );
+ }
+ } else {
+ _e( 'Last Modified' );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $format = get_post_format( $post->ID ) ) {
- $label = get_post_format_string( $format );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @since 4.3.0
+ *
+ * @param WP_Post $post
+ */
+ public function column_comments( $post ) {
+ ?>
+ <div class="post-com-count-wrapper">
+ <?php
+ $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 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> ";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->comments_bubble( $post->ID, $pending_comments );
+ ?>
+ </div>
+ <?php
+ }
+
+ /**
+ * @since 4.3.0
+ *
+ * @param WP_Post $post
+ */
+ public function column_author( $post ) {
+ printf( '<a href="%s">%s</a>',
+ esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
+ get_the_author()
+ );
+ }
+
+ /**
+ * @since 4.3.0
+ *
+ * @param WP_Post $post
+ * @param string $column_name
+ */
+ public function column_default( $post, $column_name ) {
+ if ( 'categories' == $column_name ) {
+ $taxonomy = 'category';
+ } elseif ( 'tags' == $column_name ) {
+ $taxonomy = 'post_tag';
+ } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
+ $taxonomy = substr( $column_name, 9 );
+ } else {
+ $taxonomy = false;
+ }
+ if ( $taxonomy ) {
+ $taxonomy_object = get_taxonomy( $taxonomy );
+ $terms = get_the_terms( $post->ID, $taxonomy );
+ if ( is_array( $terms ) ) {
+ $out = array();
+ foreach ( $terms as $t ) {
+ $posts_in_term_qv = array();
+ if ( 'post' != $post->post_type ) {
+ $posts_in_term_qv['post_type'] = $post->post_type;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ( $can_edit_post && $post->post_status != 'trash' ) {
- echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $taxonomy_object->query_var ) {
+ $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo $pad . $title;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $posts_in_term_qv['taxonomy'] = $taxonomy;
+ $posts_in_term_qv['term'] = $t->slug;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- _post_states( $post );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $parent_name ) )
- echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $out[] = sprintf( '<a href="%s">%s</a>',
+ esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
+ esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
+ );
+ }
+ /* translators: used between list items, there is a space after the comma */
+ echo join( __( ', ' ), $out );
+ } else {
+ echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->not_found . '</span>';
+ }
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo "</strong>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_post_type_hierarchical( $post->post_type ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $can_edit_post && $post->post_status != 'trash' ) {
- if ( $lock_holder ) {
- $locked_avatar = get_avatar( $lock_holder->ID, 18 );
- $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
- } else {
- $locked_avatar = $locked_text = '';
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Fires in each custom column on the Posts list table.
+ *
+ * This hook only fires if the current post type is hierarchical,
+ * such as pages.
+ *
+ * @since 2.5.0
+ *
+ * @param string $column_name The name of the column to display.
+ * @param int $post_id The current post ID.
+ */
+ do_action( 'manage_pages_custom_column', $column_name, $post->ID );
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Fires in each custom column in the Posts list table.
+ *
+ * This hook only fires if the current post type is non-hierarchical,
+ * such as posts.
+ *
+ * @since 1.5.0
+ *
+ * @param string $column_name The name of the column to display.
+ * @param int $post_id The current post ID.
+ */
+ do_action( 'manage_posts_custom_column', $column_name, $post->ID );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
- the_excerpt();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Fires for each custom column of a specific post type in the Posts list table.
+ *
+ * The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
+ *
+ * @since 3.1.0
+ *
+ * @param string $column_name The name of the column to display.
+ * @param int $post_id The current post ID.
+ */
+ do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_inline_data( $post );
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @since 4.3.0
+ *
+ * @param WP_Post $post
+ */
+ public function single_row_columns( $item ) {
+ list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- case 'date':
- if ( '0000-00-00 00:00:00' == $post->post_date ) {
- $t_time = $h_time = __( 'Unpublished' );
- $time_diff = 0;
- } else {
- $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
- $m_time = $post->post_date;
- $time = get_post_time( 'G', true, $post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $columns as $column_name => $column_display_name ) {
+ $classes = "$column_name column-$column_name";
+ if ( $primary === $column_name ) {
+ $classes .= ' has-row-actions column-primary';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $time_diff = time() - $time;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'title' === $column_name ) {
+ $classes .= ' page-title'; // Special addition for title column
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
- $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
- else
- $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( in_array( $column_name, $hidden ) ) {
+ $classes .= ' hidden';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'excerpt' == $mode ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attributes = "class='$classes'";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Filter the published time of the post.
- *
- * If $mode equals 'excerpt', the published time and date are both displayed.
- * If $mode equals 'list' (default), the publish date is displayed, with the
- * time and date together available as an abbreviation definition.
- *
- * @since 2.5.1
- *
- * @param array $t_time The published time.
- * @param WP_Post $post Post object.
- * @param string $column_name The column name.
- * @param string $mode The list display mode ('excerpt' or 'list').
- */
- echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
- } else {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'cb' === $column_name ) {
+ $this->column_cb( $item );
+ } else {
+ echo "<td $attributes>";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
- echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
- }
- echo '<br />';
- if ( 'publish' == $post->post_status ) {
- _e( 'Published' );
- } elseif ( 'future' == $post->post_status ) {
- if ( $time_diff > 0 )
- echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
- else
- _e( 'Scheduled' );
- } else {
- _e( 'Last Modified' );
- }
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( method_exists( $this, 'column_' . $column_name ) ) {
+ call_user_func( array( $this, 'column_' . $column_name ), $item );
+ } else {
+ $this->column_default( $item, $column_name );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- case 'comments':
- ?>
- <div class="post-com-count-wrapper">
- <?php
- $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo $this->handle_row_actions( $item, $column_name, $primary );
+ echo '</td>';
+ }
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->comments_bubble( $post->ID, $pending_comments );
- ?>
- </div>
- <?php
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @global WP_Post $post
+ *
+ * @param int|WP_Post $post
+ * @param int $level
+ */
+ public function single_row( $post, $level = 0 ) {
+ $global_post = get_post();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- case 'author':
- printf( '<a href="%s">%s</a>',
- esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
- get_the_author()
- );
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post );
+ $this->current_level = $level;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- default:
- if ( 'categories' == $column_name )
- $taxonomy = 'category';
- elseif ( 'tags' == $column_name )
- $taxonomy = 'post_tag';
- elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
- $taxonomy = substr( $column_name, 9 );
- else
- $taxonomy = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $GLOBALS['post'] = $post;
+ setup_postdata( $post );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $taxonomy ) {
- $taxonomy_object = get_taxonomy( $taxonomy );
- $terms = get_the_terms( $post->ID, $taxonomy );
- if ( is_array( $terms ) ) {
- $out = array();
- foreach ( $terms as $t ) {
- $posts_in_term_qv = array();
- if ( 'post' != $post->post_type )
- $posts_in_term_qv['post_type'] = $post->post_type;
- if ( $taxonomy_object->query_var ) {
- $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
- } else {
- $posts_in_term_qv['taxonomy'] = $taxonomy;
- $posts_in_term_qv['term'] = $t->slug;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out[] = sprintf( '<a href="%s">%s</a>',
- esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
- esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
- );
- }
- /* translators: used between list items, there is a space after the comma */
- echo join( __( ', ' ), $out );
- } else {
- echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->not_found . '</span>';
- }
- break;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $lock_holder = wp_check_post_lock( $post->ID );
+ if ( $lock_holder ) {
+ $classes .= ' wp-locked';
+ $lock_holder = get_userdata( $lock_holder );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_post_type_hierarchical( $post->post_type ) ) {
-
- /**
- * Fires in each custom column on the Posts list table.
- *
- * This hook only fires if the current post type is hierarchical,
- * such as pages.
- *
- * @since 2.5.0
- *
- * @param string $column_name The name of the column to display.
- * @param int $post_id The current post ID.
- */
- do_action( 'manage_pages_custom_column', $column_name, $post->ID );
- } else {
-
- /**
- * Fires in each custom column in the Posts list table.
- *
- * This hook only fires if the current post type is non-hierarchical,
- * such as posts.
- *
- * @since 1.5.0
- *
- * @param string $column_name The name of the column to display.
- * @param int $post_id The current post ID.
- */
- do_action( 'manage_posts_custom_column', $column_name, $post->ID );
- }
-
- /**
- * Fires for each custom column of a specific post type in the Posts list table.
- *
- * The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
- *
- * @since 3.1.0
- *
- * @param string $column_name The name of the column to display.
- * @param int $post_id The current post ID.
- */
- do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
- break;
- }
-
- echo $this->handle_row_actions( $post, $column_name, $primary );
- echo '</td>';
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $post->post_parent ) {
+ $count = count( get_post_ancestors( $post->ID ) );
+ $classes .= ' level-'. $count;
+ } else {
+ $classes .= ' level-0';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
+ <?php $this->single_row_columns( $post ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['post'] = $global_post;
</span></span></pre>
</div>
</div>
</body>
</html>