WordPress.org

Making WordPress.org

Opened 2 years ago

Closed 2 years ago

Last modified 12 months ago

#1353 closed defect (maybelater)

Remove wp_title uses in wordpress.org themes

Reported by: atimmer Owned by:
Milestone: Priority: normal
Component: General Keywords: has-patch
Cc:

Description

We should remove wp_title uses from all the wordpress.org themes given that wp_title is now deprecated.

To generate a list of uses of wp_title, you can use this in the meta environment directory:

ag "wp_title[^_]" --ignore="wp-includes" --ignore="twentythirteen" --ignore="twentyfourteen" --ignore="twentyeleven" --ignore="twentytwelve" --ignore="twentyten" --ignore="jetpack" --php

Attachments (4)

1353.diff (2.3 KB) - added by BandonRandon 2 years ago.
1353-mobileapps.diff (1.4 KB) - added by BandonRandon 2 years ago.
1353-mobileapps_2.diff (1.4 KB) - added by BandonRandon 2 years ago.
forgot document_title_separator filter :)
1353.wporg-forums.diff (1.3 KB) - added by coffee2code 2 years ago.
Patch to update wporg-forums. (see comment #11 for context.

Download all attachments as: .zip

Change History (17)

#1 @Otto42
2 years ago

Are there any themes used which don't have the header.php overridden by a child theme which is calling the universal dotorg/header.php file?

I ask because the dotorg/header.php file does not use wp_title().

If the existing themes update, then it won't affect the child themes. Which means this ticket is invalid.

Last edited 2 years ago by Otto42 (previous) (diff)

#2 @atimmer
2 years ago

I stumbled upon the deprecation warning when working on a local copy of developer.wordpress.org, so at least that one needs to be removed: https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/header.php#L10.

I searched the other meta sites and assumed all uses of wp_title should be removed. Am I misinformed here?

#3 @BandonRandon
2 years ago

  • Cc bandonrandon@… added
  • Keywords needs-refresh has-patch added; needs-patch removed

I started looking into this and found the following meta sites seem to be using the title

  • developer.wordpress.org
  • learn.wordpress.org
  • make.wordpress.org
  • apps.wordpress.org

Maybe others.

I did a quick patch for developer.wordpress.org but it may need to be rewritten to account for the various global and separators.

@BandonRandon
2 years ago

#4 @BandonRandon
2 years ago

Here is a patch for apps.wordpress.org which is a bit simpler as it does not use the $GLOBALS['pagetitle']

It does appear that when switching to title-tag the front page name is displayed in the title bar when that is not the case when using wp_title() this may be an issue with the feature as it comes to 4.4 and will be fixed before release.

@BandonRandon
2 years ago

forgot document_title_separator filter :)

#5 @coffee2code
2 years ago

In 2010:

developer.wordpress.org: Accommodate deprecation of wp_title().

Note: Because the global W.org header requires the title to be passed via $GLOBALS['pagetitle'], add_theme_support( 'title-tag') can't be used.

  • Get title via wp_get_document_title() instead of wp_title().
  • Filter 'document_title_separator' to customize the title separator.
  • Hook 'wporg_developer_wp_title' to filter 'document_title_parts' instead of 'wp_title'.
  • Update wporg_developer_wp_title() to account for new args being passed to it.
  • Omit 'Home' from title of home page.

Props coffee2code, BandonRandon.
See #1353.

#6 @coffee2code
2 years ago

In 2011:

apps.wordpress.org: Handle deprecation of wp_title().

  • Remove direct output of <title> and use of wp_title().
  • Add add_theme_support( 'title-tag' ).
  • Filter 'document_title_separator' to customize the title separator.
  • Omit page name from title of front page.

Props BandonRandon.
See #1353.

#7 @coffee2code
2 years ago

In 2042:

apps.wordpress.org: Filter 'document_title_parts' instead of the deprecated 'wp_title' to customize document title. See #1353.

#8 @coffee2code
2 years ago

In 2043:

learn.wordpress.org: Use wp_get_document_title() instead of the deprecated wp_title().

Also ensure front page document title omits front page's title ("Front Page").

See #1353.

#9 @coffee2code
2 years ago

In 2044:

Make home: Use wp_get_document_title() instead of the deprecated wp_title().

Also ensure front page document title omits front page's title ("Making WordPress").

See #1353.

#10 @coffee2code
2 years ago

In 2045:

W.org P2 child theme: Use wp_get_document_title() instead of the deprecated wp_title(). See #1353.

#11 @coffee2code
2 years ago

In 2077:

W.org Showcase: Handle deprecation of wp_title().

  • Get title via wp_get_document_title() instead of wp_title().
  • Hook 'document_title_parts' to customize document title rather than doing so in header.php.
  • Adjust breadcrumb to use wp_get_document_title() instead of wp_title().
  • Filter 'document_title_separator' to customize the title separator.
  • Omit front page's title ('Home') from front page document title.

See #1353.

@coffee2code
2 years ago

Patch to update wporg-forums. (see comment #11 for context.

#12 @coffee2code
2 years ago

  • Keywords needs-refresh removed
  • Resolution set to maybelater
  • Status changed from new to closed

The deprecation of wp_title() has been reverted as of [core-35624].

The commits referencing this ticket above have converted all existing meta .org themes away from using wp_title() except for wporg-forums. I've attached a patch (1353.wporg-forums.diff) that updates the theme in the same fashion as the others. However, it includes a workaround for bbPress (which still only hooks the 'wp_title' filter but not the newer 'document_title_parts' filter). Since the deprecation has been reverted the need to update is not as pressing so it'd be better to hold off updating wporg-forums until bbPress makes a related update (specifically, to filter 'document_title_parts' as an alternative to 'wp_title').

Last edited 2 years ago by coffee2code (previous) (diff)

This ticket was mentioned in Slack in #meta by ocean90. View the logs.


12 months ago

Note: See TracTickets for help on using tickets.