Make WordPress Core

Ticket #47640: 47640.diff

File 47640.diff, 1.7 KB (added by pbiron, 3 years ago)
  • src/wp-admin/includes/class-wp-posts-list-table.php

    From f5c1c7944e53e7769b1711f20eaf45de4bc89bf1 Mon Sep 17 00:00:00 2001
    From: Paul Biron <paul@sparrowhawkcomputing.com>
    Date: Sat, 8 May 2021 12:35:15 -0600
    Subject: [PATCH] Add 'user_posts_{$post_type}_count'  and 'user_posts_count'
     filters for filtering the number of posts authored by the current user.
    
    ---
     .../includes/class-wp-posts-list-table.php    | 22 +++++++++++++++++++
     1 file changed, 22 insertions(+)
    
    diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php
    index 860e48e58f..764a79b70a 100644
    a b class WP_Posts_List_Table extends WP_List_Table { 
    102102                        )
    103103                );
    104104
     105                /**
     106                 * Filters the count of posts in the "Mine" view of `WP_Posts_List_Table`.
     107                 *
     108                 * The dynamic portion of the hook name, `$post_type`, refers to the post
     109                 * type slug.
     110                 *
     111                 * @since 5.8.0
     112                 *
     113                 * @param int $post_count Count of posts authored by the current user.
     114                 */
     115                $this->user_posts_count = apply_filters( "user_posts_{$post_type}_count", $this->user_posts_count );
     116
     117                /**
     118                 * Filters the count of posts in the "Mine" view of `WP_Posts_List_Table`.
     119                 *
     120                 * @since 5.8.0
     121                 *
     122                 * @param int    $post_count Count of posts authored by the current user.
     123                 * @param string $post_type  The post type.
     124                 */
     125                $this->user_posts_count = apply_filters( 'user_posts_count', $this->user_posts_count, $post_type );
     126
    105127                if ( $this->user_posts_count
    106128                        && ! current_user_can( $post_type_object->cap->edit_others_posts )
    107129                        && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] )