WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 6 months ago

#44923 new enhancement

Filter .children class on nested comments list

Reported by: greenshady Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Comments Keywords: needs-patch
Focuses: Cc:
PR Number:

Description

The start_lvl() method of Walker_Comment should have a filter hook to customize the .children class. This will allow theme authors to utilize their preferred system or CSS framework for handling nested comment lists. And, .children is generic and requires writing nested CSS selectors to target it.

This change would put the comment walker on par with the nav menu walker, where we have the nav_menu_submenu_css_class filter hook.

Attachments (2)

44923.patch (953 bytes) - added by Shizumi 13 months ago.
44923.2.patch (1.3 KB) - added by Shizumi 6 months ago.

Download all attachments as: .zip

Change History (9)

This ticket was mentioned in Slack in #themereview by greenshady. View the logs.


13 months ago

#2 @joyously
13 months ago

I'm all for parity, but when I tried to make my menu work with CSS only, I had to insert elements at the parent level of the submenu, not at the child level. So while this filter would be good for comments, it would have the same problem of not being able to inject something at the parent level, which is how you have to work with CSS.

In my case, I had to supply an entire nav walker class just to output a small piece of HTML to be able to trigger the submenus. Comments are a bit less dynamic, but same nested lists.

What I'm saying is: is a filter enough?

#3 @greenshady
13 months ago

Yes, a filter is plenty when all you need to do is alter a class.

It sounds like the issues you're describing are out of scope for this proposed enhancement.

#4 @SergeyBiryukov
13 months ago

  • Keywords needs-patch added

@Shizumi
13 months ago

#5 @Shizumi
13 months ago

I made a patch.
Because it is the first time, please let me know if there is a shortage.

#6 @greenshady
8 months ago

The filter hook might be more appropriately named comment_list_sublist_class or something to that effect. Other ideas?

Also, $class_names needs to be wrapped in esc_attr() when adding to the HTML.

@Shizumi
6 months ago

#7 @Shizumi
6 months ago

Thank you for your comment.
I tried to rewrite it.

Note: See TracTickets for help on using tickets.