WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 6 weeks ago

#26746 new enhancement

Avoid translating several times post type and taxonomy default labels

Reported by: Chouby Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: needs-patch
Focuses: performance Cc:

Description

get_taxonomy_labels and get_post_type_labels translate default labels each time register_post_type and register_taxonomy are called. This is useless and is a rather expensive process resulting in a performance loss.

Attachments (2)

26746.patch (5.6 KB) - added by Chouby 4 months ago.
26746.2.patch (5.9 KB) - added by Chouby 6 weeks ago.

Download all attachments as: .zip

Change History (6)

Chouby4 months ago

comment:1 Chouby4 months ago

  • Keywords has-patch added

comment:2 nacin3 months ago

  • Component changed from Performance to Post Types
  • Focuses performance added
  • Milestone changed from Awaiting Review to 3.9

comment:3 nacin7 weeks ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 3.9 to Future Release

I'm all for performance improvements here but, as written, this will break translations. Right now core post types and taxonomies are loaded twice, and the first time is before translations are loaded. These would thus always be in English.

A lesser concern could be someone switching between languages (such as each language being a post type), but they're likely going to have their own strings/labels, so it's not as big of a deal and probably an edge case.

Chouby6 weeks ago

comment:4 Chouby6 weeks ago

Yes you are right. It breaks translations. So we can't do that before the default textdomain is loaded. In the second patch, I propose to wait for the 'init' action. The benefit would not be so high for a default WordPress install, but could still be interesting for an install with lot of custom post types and taxonomies (provided that they are registered in an init action as recommended).

Note: See TracTickets for help on using tickets.