Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#28442 closed enhancement (worksforme)

New filter for post status links (in admin)

Reported by: khromov's profile khromov Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Administration Keywords: has-patch reporter-feedback 2nd-opinion
Focuses: administration Cc:


I'm proposing the addition of a filter, "post_status_links", to let plugins modify the post status links, as displayed in this picture:

There is already exactly this type of filter in class-wp-comments-list-table.php called "comment_status_links", which you can see here:

I am proposing we add this to posts as well, and possibly to all the admin list templates at some point.

There are multiple use cases here, such as changing the post counts, adding custom links, hiding some of the links.

Attached you will find a diff again trunk.

Attachments (2)

class-wp-posts-list-table.php.patch (725 bytes) - added by khromov 10 years ago.
class-wp-posts-list-table.php.2.patch (616 bytes) - added by khromov 10 years ago.
Attached a new patch with some comment clarifications.

Download all attachments as: .zip

Change History (7)

10 years ago

Attached a new patch with some comment clarifications.

#1 @ryanshoover
10 years ago

  • Focuses administration added
  • Keywords has-patch added
  • Resolution set to worksforme
  • Status changed from new to closed

Filter works great for me. This is a good addition for plugins that develop a more extensive workflow for WP posts.

Would it also be useful to add filters to the $total_posts variable and $status_name variable to make editing the core list easier? Otherwise someone would need to directly edit the string.

#2 @kpdesign
10 years ago

  • Component changed from General to Administration
  • Resolution worksforme deleted
  • Status changed from closed to reopened

@ryanshoover: Thank you for your feedback on khromov's patch, I'm glad it works for you.

I've reopened the ticket so the patch can be reviewed, and feedback provided on the idea by members of the core team and other contributors.

#3 @kpdesign
10 years ago

@khromov: Thank you for the patch.

Just a couple notes on the docs:

  • The @since needs to be 3-digit (4.0.0) per the inline docs standard.
  • I would suggest changing the parameter description to include the defaults, in keeping with how other similar descriptions are written:
@param array $status_links An array of fully-formed post status links. Default 'All'.
                           Accepts 'All', 'Mine', 'Published', 'Sticky', 'Draft',
                           'Pending', and 'Trash'.

#4 @johnbillion
10 years ago

  • Keywords reporter-feedback 2nd-opinion added

There's already a views_{$screen_id} filter available for this. Granted, it's not a great name and it's not very discoverable, but it's there. Does your proposed filter enable anything that this existing filter doesn't?

#5 @helen
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from reopened to closed
  • Version changed from trunk to 3.9

johnbillion is correct, views_{$screen_id} is very likely what you're looking for. Feel free to reopen if we've missed a detail here.

Note: See TracTickets for help on using tickets.