WordPress.org

Make WordPress Core

Opened 20 months ago

Last modified 13 months ago

#38218 new enhancement

Introduce a WP_Post_Type_Labels class

Reported by: swissspidy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

This came up while working on #38157 and #26511.

Moving the logic from get_post_type_labels() into its own class would greatly benefit the efforts made to switch locales. It essentially replaces the post type labels object with a new class that returns the labels on the fly (note: includes tests from #38157). The downside is that labels are never stored in an array but always translated upon request (performance problems?).

What's needed for just-in-time translation (in addition to the current patch) is probably allowing passing a callback instead of an array of labels to the function. The same would need to be done for custom taxonomies and perhaps post statuses.

Attachments (1)

38218.diff (14.4 KB) - added by swissspidy 20 months ago.

Download all attachments as: .zip

Change History (3)

@swissspidy
20 months ago

#1 @swissspidy
19 months ago

  • Type changed from defect (bug) to enhancement

#2 @swissspidy
13 months ago

In 40635:

Posts, Post Types: Add initial tests for get_post_type_labels().

See #38218.
Fixes #38157.

Note: See TracTickets for help on using tickets.