WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 9 days ago

#51643 new enhancement

Function capital_P_dangit is applied directly to document title

Reported by: dragunoff Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Formatting Keywords: needs-patch good-first-bug
Focuses: Cc:

Description

This formatting function is normally applied via filters. But in wp_get_document_title it's called directly and thus its effect is forced onto the user. It should instead be hooked to the filter document_title_parts.

Change History (1)

#1 @jeremyfelt
9 days ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

It does seem odd that wptexturize(), convert_chars(), and capital_P_dangit() are all run on the title after the document_title_parts filter is applied in wp_document_title().

I'm not sure if we can adjust the order now that it's been there for a few years, but it looks like there's room for a document_title filter that is applied before wp_document_title() returns $title. We can then use the familiar pattern (default-filters.php) to apply each of those in a way that can be unhooked.

Because wp_document_title() is expected to return a string safe for use in <title></title>, esc_html() should probably be run after the document_title filter is applied.

Last edited 9 days ago by jeremyfelt (previous) (diff)
Note: See TracTickets for help on using tickets.