Opened 3 years ago

Last modified 2 years ago

#15046 new defect (bug)

places where the_title is used instead of the_title_attribute

Reported by: drzraf Owned by:
Priority: normal Milestone: Awaiting Review
Component: Formatting Version: 2.3
Severity: minor Keywords: has-patch
Cc: raphael.droz@…

Description

[context]
Semantic-web/metadata related plugins popups more and more.
There is no way to filter according to specific tasks (semantic, style, content, ...)
So monolithic the_title and the_author filters are increasingly used.

the_title_attribute [6132] and the_author_meta [11138] partly address the issue
context

Here are the places where the 'content'-oriented function should be used instead of the 'display'
or 'semantic'-oriented versions (often in the 'title' attribute of <a>) :

default-widgets.php, author-template.php and twentyten/functions.php (patches attached)

Attachments (5)

default-widgets_the_title_attribute.patch (797 bytes) - added by drzraf 3 years ago.
author-template_get_the_author_meta.patch (594 bytes) - added by drzraf 3 years ago.
twentyten_get_the_author_meta.patch (591 bytes) - added by drzraf 3 years ago.
rel_links_strip_tags.patch (878 bytes) - added by drzraf 3 years ago.
feed_links_extra_the_title_attribute.1.patch (703 bytes) - added by drzraf 3 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 follow-up: ↓ 2   nacin3 years ago

I'm not sure of the purpose of get_the_author() to using the author meta function, but the use of the_title_attribute there looks sane.

Only thing is, we'll want to remove our esc_attr(). Also, maybe we take all of that logic (the anchor text too) and make it less redundant, that way we're not calling it so many times.

comment:2 in reply to: ↑ 1   drzraf3 years ago

  • Cc raphael.droz@… added

Replying to nacin:

I'm not sure of the purpose of get_the_author() to using the author meta function, but the use of the_title_attribute there looks sane.

About the_author_meta(): themes often uses get_the_author() when they just want the 'display name' string (in the "title" attribute of <a>)
The purpose of author-template_get_the_author_meta.patch is to use the unfiltered content in the_author_posts_link() of author-template.php
Thus, doing the following

add_filter('the_author', 'hook');
function hook($author) {
   return "<span rel='sioc:has_creator'>$author</span>";
}

doesn't put garbage in <a> @title.

Only thing is, we'll want to remove our esc_attr(). Also, maybe we take all of that logic (the anchor text too) and make it less redundant, that way we're not calling it so many times.

I'm not sure to get it (do you have a ticket reference about this ?)
The question I see is :
When we want an 'unfiltered' version of the content :
1) do we want a partly-filtered content (with only hooks about style|meta|... applied) ?
2) do we want a filtered content where html is stripped ?
3) do we want a filtered content where html is escaped ?
4) do we want an unfiltered content coming directly from the DB ?
...
As it's not quite clear for me (and I'm new to WP code) some patches here use 1) (changing the_title to the_title_attribute) while some others use 3) (adding strip_tags())

I would happily follow existing guidelines/past consideration on this topic if I can find them.

  • Keywords has-patch added

What nacin was trying to say is that the_title_attribute() is already escaped, so you don't need to pass it through esc_attr() or esc_html() again.

Also, big +1 on removing title attributes that are identical to the link text.

  • Version set to 2.3

Related: #16783

Note: See TracTickets for help on using tickets.