WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 months ago

Last modified 3 months ago

#15046 closed defect (bug) (fixed)

places where the_title is used instead of the_title_attribute

Reported by: drzraf Owned by: nacin
Milestone: 3.9 Priority: normal
Severity: minor Version: 2.3
Component: Formatting Keywords: has-patch
Focuses: Cc:

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 (6)

default-widgets_the_title_attribute.patch (797 bytes) - added by drzraf 4 years ago.
author-template_get_the_author_meta.patch (594 bytes) - added by drzraf 4 years ago.
twentyten_get_the_author_meta.patch (591 bytes) - added by drzraf 4 years ago.
rel_links_strip_tags.patch (878 bytes) - added by drzraf 4 years ago.
feed_links_extra_the_title_attribute.1.patch (703 bytes) - added by drzraf 4 years ago.
15046.2.patch (1.3 KB) - added by c3mdigital 8 months ago.

Download all attachments as: .zip

Change History (16)

comment:1 follow-up: nacin4 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 drzraf4 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.

comment:3 scribu4 years ago

  • 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.

comment:4 scribu4 years ago

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

comment:5 nacin3 years ago

  • Version set to 2.3

comment:6 scribu3 years ago

Related: #16783

comment:7 c3mdigital8 months ago

  • Keywords needs-refresh added

c3mdigital8 months ago

comment:8 c3mdigital8 months ago

  • Keywords needs-refresh removed

15046.2 removes redundant title from title attribute in default-widgets and refreshes feed-links patch.

comment:9 nacin3 months ago

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

In 26975:

Use the_title_attribute() in feed_links_extra(), rather than get_the_title().

props c3mdigital.
fixes #15046.

comment:10 nacin3 months ago

  • Milestone changed from Awaiting Review to 3.9
Note: See TracTickets for help on using tickets.