Make WordPress Core

Opened 3 weeks ago

Last modified 3 weeks ago

#61555 new enhancement

Add deprecation notice to wp_title()

Reported by: bedas's profile bedas Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: needs-docs 2nd-opinion
Focuses: Cc:

Description (last modified by sabernhardt)

The function wp_title() simply never considers is_front_page to be true, and as such is broken.

Legacy themes for example use wp_title, see #57778, and the Codex itself still says you must use it, although I know that is not true anymore, in fact nowadays you must use add_theme_support instead.

---

I suggest to add a deprecation notice to this function, because afaik it is not used in wp-core and as such, since broken anyway, shouldn't be possible to be used in new code, and old code should be warned, if using it.

Change History (3)

#1 @sabernhardt
3 weeks ago

  • Description modified (diff)
  • Keywords needs-patch removed
  • Type changed from defect (bug) to enhancement
  • Version trunk deleted

[35624] purposely un-deprecated wp_title(), and the oldest five bundled themes still use it. Block themes should not need either wp_title() or add_theme_support( 'title-tag' ), though they still have a bug with network signup and activation pages (#55023).

Of course, the documentation can be corrected and improved. The Codex is severely outdated overall but not yet fully replaced. I could remove the wp_title mentions in the Theme Development Codex page, but that probably should link to the Title Tag page while it remains available there. Or at least I could remove the "See why" link to a missing note that was deleted even before redirecting the page in 2015.

#2 @sabernhardt
3 weeks ago

I made a few Codex changes for now:

  • Replaced the sentence about `wp_title` with "Use the Title_Tag theme feature to set the <title> element within wp_head()" (and moved it below the list item about wp_head()).
  • Updated the Document Header section in the Spanish page (which was not translated anyway) to match the revised English content.
  • Removed the hardcoded title and stylesheet from the examples in the Korean and Chinese pages.

#3 @bedas
3 weeks ago

I am not sure to understand why "just" because some older software still uses certain functions, functions are undeprecated.
I am sure we could find hundreds or more plugins/themes that use deprecated functions, yet we wouldn't undeprecate them, rather we'd ask or expect those plugins/themes to update.

The risk at not deprecating, or putting a "doing it wrong" in place (I guess this could also be done dynamically depending on theme or wp version running) is that developers use it. They do not always rely on the documentation.

---

Note that I had opened tickets about the wrong link to a missing note in the codex, see

---

Thanks for the changes made!

Note: See TracTickets for help on using tickets.