WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#43743 new defect (bug)

Terms list table should be full width when user cannot edit terms

Reported by: swissspidy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: Taxonomy Keywords: has-screenshots good-first-bug ui-feedback has-patch
Focuses: administration Cc:

Description

The edit-tags.php screen is split into two columns. On the left hand side is a form to create new terms, on the right hand side is the list of existing terms.

Now, the form is only visible if the user has the edit_terms capability for the current taxonomy. If they don't, the left column is simply empty.

Instead of wasting this space, I'd suggest to make the list table take the full width of the screen instead of residing at the right side.

Unfortunately this can't be yet achieved using CSS alone because #col-left isn't empty as it contains a .col-wrap div.

If we'd move the current_user_can( $tax->cap->edit_terms ) check outside .col-wrap or even #col-left, we could use something like #col-left:empty #col-right { float: none; width: 100% }

Attachments (3)

list-table-float-right.png (84.6 KB) - added by swissspidy 2 months ago.
Status quo
list-table-float-none.png (91.4 KB) - added by swissspidy 2 months ago.
Proposed solution
43743.diff (1.0 KB) - added by mathieuhays 2 months ago.

Download all attachments as: .zip

Change History (7)

@swissspidy
2 months ago

Status quo

@swissspidy
2 months ago

Proposed solution

#1 @swissspidy
2 months ago

  • Keywords needs-patch good-first-bug ui-feedback added

#2 @danieltj
2 months ago

I'd suggest hiding the div completely (not using CSS) if it's empty so it's not present in the DOM as it doesn't need to exist on the page if empty. What scenario allows you to access this page but not add new terms? What role do you need to have/setup to test this?

#3 @swissspidy
2 months ago

What scenario allows you to access this page but not add new terms? What role do you need to have/setup to test this?

This happens when you have the manage_terms capability for that taxonomy but not edit_terms.

In my case, the custom taxonomy was registered with caps like these:

'capabilities'          => [
        'manage_terms' => 'manage_categories',
        'edit_terms'   => 'manage_business_areas',
        'delete_terms' => 'manage_business_areas',
        'assign_terms' => 'edit_posts',
],

Categories being a default taxonomy, I had the manage_categories caps but since I haven't yet added the custom manage_business_areas cap to my user / role, the demonstrated scenario happens.

You could easily test it by manually removing the edit_categories capability using something like the Members plugin.

@mathieuhays
2 months ago

#4 @mathieuhays
2 months ago

  • Keywords has-patch added; needs-patch removed

I've implemented a patch adding a variable $has_2_columns_layout governing whether or not to add the col_left col_right markup.

Note: See TracTickets for help on using tickets.