Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#27944 closed enhancement (fixed)

Allow Native Styling of Comment Authors' Names in the .widget_recent_comments Widget

Reported by: emg's profile EMG Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.0 Priority: normal
Severity: normal Version: 2.2
Component: Widgets Keywords: good-first-bug has-patch commit
Focuses: Cc:

Description

As it currently stands, WP's native Recent Comments widget (.widget_recent_comments) which displays a list of the most Recent Comments allows CSS styling of the Comment Author (for example, bolding)... but only in an indirect manner.

If and only if the Comment Author has a website linked to them, stylization is made possible by targeting the .url class found in the site link associated with the Author, hence, 'indirect manner'.

Unfortunately, if the Comment Author has no website linked to them, then there is no native stylization option possible to style the Comment Author's name with without styling the entire comment listing via the .recentcomments class.

I know I could maybe write a function or install other plugins to give me more control over such a thing, but it would be nice if WP itself offered it as a default option.

A span tag around Comment Author's names, maybe, to allow direct style targeting regardless if the Comment Author has a linked website or not?

Thank you!

Attachments (3)

default-widgets.php.patch (1.1 KB) - added by 5um17 11 years ago.
Wrapping author name in cite tag
27944.patch (1.2 KB) - added by dannydehaan 11 years ago.
Wrapped get_comment_author_link in a span
27944.2.patch (1.2 KB) - added by DrewAPicture 10 years ago.
.comment-author-link

Download all attachments as: .zip

Change History (18)

#1 @SergeyBiryukov
11 years ago

  • Keywords needs-patch good-first-bug added

@5um17
11 years ago

Wrapping author name in cite tag

#2 @EMG
11 years ago

Wow, that was quick! :)

I'm currently stuck on a legacy machine running XP with not much space left and not much memory and so I don't have a localhost install of WordPress (yet) for me to do a good test with. Going to try to clean up my machine a bit and set up a proper testing environment so I can apply the patch and report back.

Thanks!

#3 follow-up: @ocean90
11 years ago

  • Milestone changed from Awaiting Review to 4.0

I propose is to use <span class="comment-author"></span> here. The cite element is not the correct element for this, see #24522 for background.

#4 @dannydehaan
11 years ago

I've wrapped the get_comment_author_link() in a span with class like ocean90 proposed.

@dannydehaan
11 years ago

Wrapped get_comment_author_link in a span

#5 in reply to: ↑ 3 @EMG
11 years ago

Replying to ocean90:

I propose is to use <span class="comment-author"></span> here. The cite element is not the correct element for this, see #24522 for background.

In working with theme development from the ground up and using nothing but WordPress' own natively outputted widgets, I also noticed that the .widget_rss also outputs the author's name of an RSSed post/article/whatever wrapped in the <cite> tag as opposed to your suggested <span class="comment-author">.

As such, I created #28188 to address this issue. :)

#6 @travisnorthcutt
11 years ago

  • Keywords has-patch added; needs-patch removed

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.


10 years ago

#8 @obenland
10 years ago

.comment-author is likely to interfere with the existing class in comments and HTML5 comments. It might break visual back compat in themes that don't have .comment-author selectors "namespaced" to comments themselves.

We should probably try to come up with either a (better) different class name, or another way to achieve the same result.

@DrewAPicture
10 years ago

.comment-author-link

#9 @DrewAPicture
10 years ago

27944.2.patch uses .comment-author-link

#10 @DrewAPicture
10 years ago

  • Keywords commit added

#11 follow-up: @obenland
10 years ago

It's more specific than .comment-author, but it's not always a comment author link. If there is no URL, it's just the comment author's name.

Is there a way to scan the .org theme repository for that class name?
While there is only one theme on wp.com that uses comment-author-link, I suspect that there might be other themes using it in the context of comment_author_link().

#12 in reply to: ↑ 11 @SergeyBiryukov
10 years ago

Replying to obenland:

Is there a way to scan the .org theme repository for that class name?

I've found 4 instances of .comment-author-link:

accelerate/style.css
radiate/style.css
spacious/style.css
suffusion/style.css

And 1325 instances of .comment-author.

#13 @obenland
10 years ago

Thanks Sergey!

While Suffusion alone has over 1,000,000 downloads, the styles associated with .comment-author-link should not be too big of a drawback:

.comment-author-link {
        padding: 0 0 5px 0;
}

The other themes have it namespaced to the comments area.

No objections to 27944.2.patch then.

#14 @obenland
10 years ago

  • Version changed from 3.9 to 2.2

Introduced in r5297. (#)

#15 @SergeyBiryukov
10 years ago

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

In 29241:

Add a class for get_comment_author_link() in Recent Comments widget.

props DrewAPicture, dannydehaan, 5um17.
fixes #27944.

Note: See TracTickets for help on using tickets.