Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 6 years ago

#9301 closed defect (bug) (fixed)

no classes on div-coment in Walker_Comment::start_el()

Reported by: docwhat's profile docwhat Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: Template Keywords: has-patch tested
Focuses: Cc:


There are no classes on Walker_Comment::start_el() when it creates a <div id="div-comment-NNNN"> node.

This makes using CSS target that node pretty hard if not impossible across browsers.

Ideally, it would have a class like "comment-body".

This is a feature aid semantic markup.

Change History (7)

#1 @docwhat
15 years ago

Example Patch

diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index a4a126b..49cdfc1 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -1221,3 +1221,3 @@ class Walker_Comment extends Walker {
                <?php if ( 'ul' == $args['style'] ) : ?>
-               <div id="div-comment-<?php comment_ID() ?>">
+               <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
                <?php endif; ?>

#2 @docwhat
15 years ago

  • Keywords has-patch added

#3 @Viper007Bond
15 years ago

Wouldn't using the parent element which has comment_class() on it work?

#4 @docwhat
15 years ago

It would have before we added the "Reply" and nested comments. But now the markup can change, on the fly, from (this is from memory, so the classes might be wrong):

<li class="comment">
  <div id="div-comment-NN" />


<li class="comment">
  <div id="div-comment-NN" />
  <div id="response" />

So you can't use a rule like:

.comment > div { ... style the body of the comment ... }

... without getting the reply box, too.

Before this change, I'd just use css like this:

.comment { border: 1px solid blue; }

But the box will bound the replies too; which isn't what I wanted.


#5 @Denis-de-Bernardy
15 years ago

  • Component changed from General to Template
  • Keywords tested added
  • Milestone changed from Unassigned to 2.8
  • Version set to 2.7

#6 @ryan
15 years ago

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

(In [10961]) Add comment-body class. Props docwhat. fixes #9301

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

6 years ago

Note: See TracTickets for help on using tickets.