WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#42997 closed enhancement (fixed)

Add filter to WP_Comments_List_Table::prepare_items get_comments arguments

Reported by: soulseekah Owned by: rachelbaker
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch
Focuses: administration Cc:

Description

Filtering the comments in the backend is quite hacky right now if not impossible.

This is a proposal to add a simple filter the $args parameter to the get_comments calls inside WP_Comments_List_Table::prepare_items.

Attachments (3)

42997.diff (701 bytes) - added by soulseekah 3 years ago.
Concept
42997.1.diff (712 bytes) - added by soulseekah 3 years ago.
Naming
42997.2.diff (555 bytes) - added by audrasjb 2 years ago.
@since refresh for 5.0.3

Download all attachments as: .zip

Change History (13)

@soulseekah
3 years ago

Concept

#1 @birgire
3 years ago

  • Component changed from Administration to Comments
  • Keywords has-patch added

Hi @soulseekah

This seems to be in line with other table query argument filters.

For example within the users list table:

 /**
  * Filters the query arguments used to retrieve users for the current users list table.
  *
  * @since 4.4.0
  *
  * @param array $args Arguments passed to WP_User_Query to retrieve items for the current
  *                    users list table.
  */
  $args = apply_filters( 'users_list_table_query_args', $args );

and within the sites list table:

/**
 * Filters the arguments for the site query in the sites list table.
 *
 * @since 4.6.0
 *
 * @param array $args An array of get_sites() arguments.
 */
$args = apply_filters( 'ms_sites_list_table_query_args', $args );

For the comments list table, I would suggest adjusting 42997.diff according to the same filter naming convention:

/**
 * Filters the arguments for the comment query in the comments list table.
 *
 * @since trunk
 *
 * @param array $args An array of get_comments() arguments.
 */
$args = apply_filters( 'comments_list_table_query_args', $args ); 

with similar adjustments to the docblock as for the sites list table.

Last edited 3 years ago by birgire (previous) (diff)

@soulseekah
3 years ago

Naming

#2 @rachelbaker
3 years ago

  • Milestone changed from Awaiting Review to 5.0
  • Version trunk deleted

#3 @rachelbaker
3 years ago

  • Owner set to rachelbaker
  • Resolution set to fixed
  • Status changed from new to closed

In 42420:

Comments: Introduce filter for the arguments for the comment query in the comments list table.

Add comments_list_table_query_args filter to the Comments List Table.

Props soulseekah, birgire.
Fixes #42997.

#4 @johnbillion
2 years ago

  • Milestone changed from 5.0 to 5.0.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

@since needs updating

#5 @pento
2 years ago

  • Milestone changed from 5.0.1 to 5.0.2

#6 @pento
2 years ago

  • Milestone changed from 5.0.2 to 5.0.3

@audrasjb
2 years ago

@since refresh for 5.0.3

#7 @audrasjb
2 years ago

  • Keywords commit added

Hi,

@since is refreshed for 5.0.3.

#8 @desrosj
2 years ago

  • Milestone changed from 5.0.3 to 5.1

This falls outside of the scope for 5.0.3. Let's aim to add the new filter in 5.1.

#9 @desrosj
2 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 44530:

Docs: Update since annotation for comments_list_table_query_args.

Introduced in [42420].

Fixes #42997.

#10 @desrosj
2 years ago

  • Keywords commit removed
Note: See TracTickets for help on using tickets.