Make WordPress Core

Opened 3 weeks ago

Last modified 9 days ago

#58318 new defect (bug)

Remove `load_theme_textdomain()` calls from default themes

Reported by: swissspidy's profile swissspidy Owned by:
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:

Description

Since WordPress 4.6 introduced just-in-time translation loading, themes and plugins no longer need to manually call load_theme_textdomain/load_plugin_textdomain, unless they are on a version prior to 4.6.

Still, for some reason the default themes before Twenty Twenty-Two still use load_theme_textdomain, sometimes even pointing to a /languages folder that doesn't actually exist.

Related: #34884

Suggestion:

  1. Remove load_theme_textdomain() call from Twenty Seventeen and up, since these themes all require at least WordPress 4.7
  2. On older default themes, only call load_theme_textdomain() conditionally depending on the WordPress version.

Attachments (1)

load-theme-textdomain.diff (10.2 KB) - added by piyushtekwani 9 days ago.

Download all attachments as: .zip

Change History (7)

#1 @spacedmonkey
3 weeks ago

If we make this change, I would like to see a dev note, so it means that others do not make the same mistake.

#2 @swissspidy
3 weeks ago

FWIW, we already had a dev note for this 7 years ago: https://make.wordpress.org/core/2016/07/06/i18n-improvements-in-4-6/

#3 @audrasjb
3 weeks ago

  • Milestone changed from Awaiting Review to 6.3

Nice catch, let's move this to milestone 6.3.

#4 @spacedmonkey
2 weeks ago

I think it is worth writing a blog post about this. I had no idea about this change. I think flagging and the performance impact it might have would go a long way to get themes to stop using these functions.

Looking at the theme directory, seems to be lots of plugins there that use it. See https://www.wpdirectory.net/search/01H0Q50AEDHDWKN0TFDZ3BJZ5M

Including storefront, Astra and OceanWP, three of the largest themes in the repo.

#5 @swissspidy
2 weeks ago

Sure we can mention this somewhere as a reminder. Not really a performance impact though

This ticket was mentioned in PR #4501 on WordPress/wordpress-develop by celestioushawk.


9 days ago
#6

  • Keywords has-patch added; needs-patch removed

Remove explicit call to load_theme_textdomain() after twentyseventeen theme since they all require WordPress version 4.6 (just in time translation loading introduced) and above. Add a wp_version conditional check for themes before twentyseventeen for a call to load_theme_textdomain() to be included.

Trac ticket: https://core.trac.wordpress.org/ticket/58318

Note: See TracTickets for help on using tickets.