Make WordPress Core

Opened 17 months ago

Closed 16 months ago

Last modified 16 months ago

#58318 closed defect (bug) (fixed)

Remove `load_theme_textdomain()` calls from default themes

Reported by: swissspidy's profile swissspidy Owned by: swissspidy's profile swissspidy
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 17 months ago.

Download all attachments as: .zip

Change History (10)

#1 @spacedmonkey
17 months 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.

#3 @audrasjb
17 months ago

  • Milestone changed from Awaiting Review to 6.3

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

#4 @spacedmonkey
17 months 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
17 months 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.


17 months 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

#7 @spacedmonkey
16 months ago

@swissspidy Do you plan to own / commit this ticket?

#8 @swissspidy
16 months ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from new to closed

In 55929:

Bundled Themes: Remove load_theme_textdomain() calls from default themes.

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.

This change removes the load_theme_textdomain() call from Twenty Seventeen and up, since these themes all require at least WordPress 4.7.
On older default themes, load_theme_textdomain() is called conditionally depending on the WordPress version.

Props piyushtekwani.
Fixes #58318.

Note: See TracTickets for help on using tickets.