#51643 closed enhancement (fixed)
Function capital_P_dangit is applied directly to document title
Reported by: | dragunoff | Owned by: | desrosj |
---|---|---|---|
Milestone: | 5.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Formatting | Keywords: | good-first-bug has-patch needs-dev-note |
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
.
Attachments (2)
Change History (12)
#1
@
4 years ago
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to Future Release
- Type changed from defect (bug) to enhancement
@
4 years ago
Create a new filter 'document_title' and hooked the wptexturize(), convert_chars(), capital_P_dangit().
#2
@
4 years ago
Hi, first time to contribute.
@jeremyfelt about the esc_html()
to run after the new filter, there is another filter wp_title
, which runs the esc_html()
before the capital_P_dangit()
, and I decided to left the same order also for the new filter.
#5
@
3 years ago
In 51643.1.diff:
- Switch a bit the order of the
document_title
parameter for better consistency. - Fix few coding standard issues in the DocBlock comments
- Add a version number in the
@since
declaration
Patch should be good to go.
This ticket was mentioned in PR #1300 on WordPress/wordpress-develop by desrosj.
3 years ago
#7
Trac ticket: https://core.trac.wordpress.org/ticket/51643
3 years ago
#9
Merged into Core in https://core.trac.wordpress.org/changeset/51019.
It does seem odd that
wptexturize()
,convert_chars()
, andcapital_P_dangit()
are all run on the title after thedocument_title_parts
filter is applied inwp_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 beforewp_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 thedocument_title
filter is applied.