Make WordPress Core

Opened 10 years ago

Closed 7 years ago

#30829 closed enhancement (fixed)

I want to add the list table views in edit-tags.php

Reported by: llemurya's profile llemurya Owned by: mariovalney's profile mariovalney
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.1
Component: Taxonomy Keywords: good-first-bug has-patch
Focuses: ui, administration Cc:

Description

I want to add some list table views in edit-tags.php page, but it is not possible without workout ,because in this page on line #326 run only this code <?php $wp_list_table->display(); ?> but I want to see
<?php $wp_list_table->views(); ?>;
<?php $wp_list_table->display(); ?>. In order to add some filters and render views.

Attachments (5)

30829.patch (518 bytes) - added by eventualo 8 years ago.
30829-2.patch (1.0 KB) - added by mariovalney 7 years ago.
30829.2.patch (561 bytes) - added by riddhiehta02 7 years ago.
Add Description to the function. Patch added.
39958.3.patch (1.1 KB) - added by mariovalney 7 years ago.
30829.3.patch (1.1 KB) - added by mariovalney 7 years ago.

Download all attachments as: .zip

Change History (17)

#1 @boonebgorges
9 years ago

I guess I'm not opposed to doing this, but as WP_Terms_List_Table is currently built, the only way you'll be able to add the views markup is by filtering 'views_edit-post_tag' and returning the link markup. IMO this is kind of a lousy UX. Better might be to introduce WP_Terms_List_Table::get_views(), which would return an empty array that'd pass through a 'term_view_links' filter or something like that. Then plugins could add their links in a more sensible way. Do you have thoughts about this?

This ticket was mentioned in Slack in #core by boone. View the logs.


8 years ago

#3 @boonebgorges
8 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

Still seems like a good idea. Patch needed.

@eventualo
8 years ago

#4 @eventualo
8 years ago

  • Keywords needs-patch removed

I've just added the 30829.patch. As suggested by @llemurya I added $wp_list_table->views() in edit-tags.php. So, like @boonebgorges remind us, it's possible to add table views using the views_edit-post_tag hook. I didn't add another filter inside get_views()/views() methods because there aren't similar filters in other posts/media edit files.

#5 @eventualo
8 years ago

  • Keywords has-patch added

#6 @mariovalney
7 years ago

  • Keywords needs-patch added; has-patch removed

@mariovalney
7 years ago

#7 @mariovalney
7 years ago

  • Keywords has-patch added; needs-patch removed

I refreshed @eventualo patch and added get_views to WP_Terms_List_Table as suggested by @boonebgorges .

The only filter I found on get_views() was comment_status_links so without another filter to compare name I kept the term_view_links suggestion but added taxonomy to support custom ones:
term_' . $this->screen->taxonomy . '_view_links

Last edited 7 years ago by mariovalney (previous) (diff)

@riddhiehta02
7 years ago

Add Description to the function. Patch added.

#8 @DrewAPicture
7 years ago

  • Owner set to mariovalney
  • Status changed from new to assigned

Assigning ownership to mark the good-first-bug as "claimed".

#9 @boonebgorges
7 years ago

  • Focuses template removed
  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Future Release to 4.9

Thanks to @mariovalney and @riddhiehta02 for your patches!

Could I please get a single, unified patch that does the following:

As long as we get this patch, it should be no problem to add for 4.9.

@mariovalney
7 years ago

@mariovalney
7 years ago

#10 @mariovalney
7 years ago

  • Keywords has-patch added; needs-patch removed

Thanks for guidelines, @boonebgorges.
Thanks for description, @riddhiehta02.

I guess 30829.3.patch is done.

P.S.: sorry for wrong number on 39958.3.patch... hahahah

Last edited 7 years ago by mariovalney (previous) (diff)

#11 @boonebgorges
7 years ago

Thank you, @mariovalney!

Earlier, I said that the views_edit-post_tag filter was cumbersome to use. As I'm reviewing the most recent patches, I'm unsure why I thought this - the proposed new filter in 30829.3.patch return exactly the same kind of data as the generic views_{$screen} filter. This is my mistake - my apologies for misreading the code. Any objections to just going with 30829.patch ?

#12 @SergeyBiryukov
7 years ago

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

In 41378:

Taxonomy: Allow for adding custom list table views to taxonomy screens.

Props eventualo, mariovalney, riddhiehta02, llemurya.
Fixes #30829.

Note: See TracTickets for help on using tickets.