Automattic / Automattic/wp-cldr
Should we make `WP_CLDR` a singleton?
- Dominant language
- PHP
- Stars
- 24
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Repeatedly creating a new instance (for repeated lookups, etc.) is an anti-pattern because of the work done during [initialization](https://github.com/Automattic/wp-cldr/blob/206e3e0cf9bbd5d8a81ebb6853b19983b9f3dcbb/class-wp-cldr.php#L92-L111). Even if we use a cache, it's a pretty big hit to do this multiple times per request.
A singleton pattern (forcing use of a `static get_instance()` method by default) would work around this.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with class-wp-cldr.php, especially the initialization code at lines 92–111, and search the repository for repeated WP_CLDR construction. Review how callers obtain instances before deciding whether static get_instance() can be adopted consistently. Done means repeated lookups avoid repeated initialization without changing existing localization behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- localization
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100