WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#25791 closed enhancement (fixed)

Add a nesting level class to <tr> elements in #the-list

Reported by: jhned Owned by: nacin
Milestone: 3.8 Priority: normal
Severity: minor Version: 3.8
Component: Administration Keywords: needs-testing has-patch
Focuses: Cc:

Description

In the admin, there's a big table (#the-list) for the list of pages. The WordPress admin file class-wp-posts-list-table.php currently adds a bunch of classes to the individual table rows for each page. What it does not add is a class for the page's nesting level.

I'd like to add one because scrolling through 100+ pages is tedious, and being able to style the different levels can be very helpful for seeing where you are at a glance.

I'm attaching a piece of code for line 494 of /wp-admin/includes/class-wp-posts-list-table.php that will add this functionality. I have tested it on the latest version of WordPress, but I'd imagine that it will require further testing if it is to be included in the core.

Attachments (2)

nesting-class-patch.php (159 bytes) - added by jhned 7 years ago.
Nesting Class Patch for class-wp-posts-list-table.php
add_nesting_class.diff (683 bytes) - added by jhned 7 years ago.
add_nesting_class.diff

Download all attachments as: .zip

Change History (8)

@jhned
7 years ago

Nesting Class Patch for class-wp-posts-list-table.php

#1 @SergeyBiryukov
7 years ago

Could you please attach an SVN patch rather than a PHP file? See http://make.wordpress.org/core/handbook/submitting-a-patch/.

@jhned
7 years ago

add_nesting_class.diff

#2 @jhned
7 years ago

Sure thing, patch added.

#3 @nacin
7 years ago

  • Milestone changed from Awaiting Review to 3.8

jhned and I worked through this at the WC Orlando contributor day. The patch looked good; the concern at that point led to whether the call to get_post_ancestors() was a performance hit, in terms of increased queries.

Normally, we have the full hierarchy already, so there is no penalty. But if a search only returns a non-top-level page, we won't yet have its ancestors. At this point, we would need to run new queries.

However, we separately need the ancestors for two other reasons. One, if pretty permalinks are turned on, we need them in get_page_uri() for the 'View' action link. Two, we need to figure out how many levels deep that page is so we can properly display its level, via em-dashes. (We also need its parent so we can show "Parent Page:", but ancestors are still needed for levels.) That particular code is in the list table — $level = 0 but we know better, so we need to calculate the depth.

add_nesting_class.diff is good to go.

#4 follow-up: @nacin
7 years ago

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

In 26244:

Add level-X classes to the posts list table rows.

props jhned.
fixes #25791.

#5 in reply to: ↑ 4 @nbachiyski
7 years ago

Replying to nacin:

In 26244:

Nacin, you left some debug in: if ( false && $post->post_parent )

#6 @SergeyBiryukov
7 years ago

In 26245:

Remove debug cruft. props nbachiyski. see #25791.

Note: See TracTickets for help on using tickets.