diff --git a/src/wp-admin/includes/class-wp-users-list-table.php b/src/wp-admin/includes/class-wp-users-list-table.php
index 9a8709b438e05..c03ee476fb398 100644
--- a/src/wp-admin/includes/class-wp-users-list-table.php
+++ b/src/wp-admin/includes/class-wp-users-list-table.php
@@ -374,7 +374,7 @@ public function get_columns() {
'name' => __( 'Name' ),
'email' => __( 'Email' ),
'role' => __( 'Role' ),
- 'posts' => _x( 'Posts', 'post type general name' ),
+ 'posts' => _x( 'Content', 'users list table authored content column name' ),
);
if ( $this->is_site_users ) {
@@ -408,7 +408,7 @@ protected function get_sortable_columns() {
public function display_rows() {
// Query the post counts for this page.
if ( ! $this->is_site_users ) {
- $post_counts = count_many_users_posts( array_keys( $this->items ) );
+ $post_counts = count_many_users_posts( array_keys( $this->items ), $this->get_countable_post_types() );
}
foreach ( $this->items as $userid => $user_object ) {
@@ -599,12 +599,11 @@ public function single_row( $user_object, $style = '', $role = '', $numposts = 0
case 'posts':
if ( $numposts > 0 ) {
$row .= sprintf(
- '%s%s',
- "edit.php?author={$user_object->ID}",
- $numposts,
+ '%s%s',
+ number_format_i18n( $numposts ),
sprintf(
- /* translators: Hidden accessibility text. %s: Number of posts. */
- _n( '%s post by this author', '%s posts by this author', $numposts ),
+ /* translators: Hidden accessibility text. %s: Number of content items. */
+ _n( '%s content item by this author', '%s content items by this author', $numposts ),
number_format_i18n( $numposts )
)
);
@@ -647,6 +646,33 @@ protected function get_default_primary_column_name() {
return 'username';
}
+ /**
+ * Returns the post types counted in the Users list table content column.
+ *
+ * Post types are limited to those with an admin UI that support authors, so the
+ * count reflects user-managed content such as posts, pages, media, and custom
+ * post types.
+ *
+ * @since 7.1.0
+ *
+ * @return string[] Post type names.
+ */
+ protected function get_countable_post_types() {
+ return array_values(
+ array_filter(
+ get_post_types(
+ array(
+ 'show_ui' => true,
+ ),
+ 'names'
+ ),
+ static function ( $post_type ) {
+ return post_type_supports( $post_type, 'author' );
+ }
+ )
+ );
+ }
+
/**
* Returns an array of translated user role names for a given user object.
*
diff --git a/tests/phpunit/tests/admin/wpUsersListTable.php b/tests/phpunit/tests/admin/wpUsersListTable.php
index 17438d074c3b4..ecb4831dba47d 100644
--- a/tests/phpunit/tests/admin/wpUsersListTable.php
+++ b/tests/phpunit/tests/admin/wpUsersListTable.php
@@ -30,4 +30,86 @@ public function test_get_views_should_return_views_by_default() {
$this->assertSame( $expected, $this->table->get_views() );
}
+
+ /**
+ * @ticket 29128
+ *
+ * @covers WP_Users_List_Table::get_columns
+ */
+ public function test_get_columns_should_label_posts_column_as_content() {
+ $columns = $this->table->get_columns();
+
+ $this->assertSame( 'Content', $columns['posts'] );
+ }
+
+ /**
+ * @ticket 29128
+ *
+ * @covers WP_Users_List_Table::display_rows
+ */
+ public function test_display_rows_should_count_authored_content_items() {
+ register_post_type(
+ 'book',
+ array(
+ 'public' => true,
+ 'show_ui' => true,
+ 'supports' => array( 'title', 'author' ),
+ )
+ );
+
+ register_post_type(
+ 'secret_note',
+ array(
+ 'public' => true,
+ 'show_ui' => false,
+ 'supports' => array( 'title', 'author' ),
+ )
+ );
+
+ $user_id = self::factory()->user->create( array( 'role' => 'author' ) );
+
+ self::factory()->post->create(
+ array(
+ 'post_author' => $user_id,
+ 'post_type' => 'post',
+ )
+ );
+
+ self::factory()->post->create(
+ array(
+ 'post_author' => $user_id,
+ 'post_type' => 'page',
+ )
+ );
+
+ self::factory()->post->create(
+ array(
+ 'post_author' => $user_id,
+ 'post_type' => 'book',
+ )
+ );
+
+ self::factory()->post->create(
+ array(
+ 'post_author' => $user_id,
+ 'post_type' => 'secret_note',
+ )
+ );
+
+ try {
+ $this->table->items = array(
+ $user_id => get_userdata( $user_id ),
+ );
+
+ ob_start();
+ $this->table->display_rows();
+ $output = ob_get_clean();
+
+ $this->assertStringNotContainsString( 'edit.php?author=' . $user_id, $output );
+ $this->assertStringContainsString( '3 content items by this author', $output );
+ } finally {
+ unregister_post_type( 'book' );
+ unregister_post_type( 'secret_note' );
+ }
+ }
}