mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Comments: Add a "Mine" link to the list of filters on the comment listing screen.
This filter shows comments made by the current user, and copies the same filter functionality that's available on the post listing screens. Props Iceable Fixes #42379 Built from https://develop.svn.wordpress.org/trunk@42684 git-svn-id: http://core.svn.wordpress.org/trunk@42512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1ae9491548
commit
ee24b48106
@ -78,7 +78,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
global $post_id, $comment_status, $search, $comment_type;
|
||||
|
||||
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
|
||||
if ( ! in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) ) {
|
||||
if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ) ) ) {
|
||||
$comment_status = 'all';
|
||||
}
|
||||
|
||||
@ -116,6 +116,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
$status_map = array(
|
||||
'mine' => '',
|
||||
'moderated' => 'hold',
|
||||
'approved' => 'approve',
|
||||
'all' => '',
|
||||
@ -222,6 +223,13 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
'comments'
|
||||
), // singular not used
|
||||
|
||||
/* translators: %s: current user's comments count */
|
||||
'mine' => _nx_noop(
|
||||
'Mine <span class="count">(%s)</span>',
|
||||
'Mine <span class="count">(%s)</span>',
|
||||
'comments'
|
||||
),
|
||||
|
||||
/* translators: %s: pending comments count */
|
||||
'moderated' => _nx_noop(
|
||||
'Pending <span class="count">(%s)</span>',
|
||||
@ -267,6 +275,17 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
$current_link_attributes = ' class="current" aria-current="page"';
|
||||
}
|
||||
|
||||
if ( 'mine' === $status ) {
|
||||
$current_user_id = get_current_user_id();
|
||||
$num_comments->mine = get_comments( array(
|
||||
'user_id' => $current_user_id,
|
||||
'count' => true,
|
||||
) );
|
||||
$link = add_query_arg( 'user_id', $current_user_id, $link );
|
||||
} else {
|
||||
$link = remove_query_arg( 'user_id', $link );
|
||||
}
|
||||
|
||||
if ( ! isset( $num_comments->$status ) ) {
|
||||
$num_comments->$status = 10;
|
||||
}
|
||||
@ -293,9 +312,10 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
* Filters the comment status links.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 5.0.0 The 'Mine' link was added.
|
||||
*
|
||||
* @param array $status_links An array of fully-formed status links. Default 'All'.
|
||||
* Accepts 'All', 'Pending', 'Approved', 'Spam', and 'Trash'.
|
||||
* @param string[] $status_links An associative array of fully-formed comment status links. Includes 'All', 'Mine',
|
||||
* 'Pending', 'Approved', 'Spam', and 'Trash'.
|
||||
*/
|
||||
return apply_filters( 'comment_status_links', $status_links );
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42683';
|
||||
$wp_version = '5.0-alpha-42684';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user