WP_Textdomain_Registry
- Since
- 6.1.0
- Source
wp-includes/class-wp-textdomain-registry.php:18
Core class used for registering text domains.
Compatibility
- WordPress
- since 6.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 2
Every hook that fires from inside WP_Textdomain_Registry, in the order it appears in the class, grouped by the method that fires it.
Properties · 5
$allarrayprotected- List of domains and all their language directory paths for each locale.
$currentarrayprotected- List of domains and their language directory path for the current (most recent) locale.
$custom_pathsarrayprotected- List of domains and their custom language directory paths.
$cached_mo_filesarrayprotected- Holds a cached list of available .mo files to improve performance.
$domains_with_translationsstring[]protected- Holds a cached list of domains with translations to improve performance.
Methods · 9
- init()Initializes the registry.
- get()Returns the languages directory path for a specific domain and locale.
- has()Determines whether any MO file paths are available for the domain.
- set()Sets the language directory path for a specific domain and locale.
- set_custom_path()Sets the custom path to the plugin's/theme's languages directory.
- get_language_files_from_path()Retrieves translation files from the specified path.
- invalidate_mo_files_cache()Invalidate the cache for .mo files.
- get_paths_for_domain()Returns possible language directory paths for a given text domain.
- get_path_from_lang_dir()Gets the path to the language directory for the current domain and locale.
Source code
#[AllowDynamicProperties]class WP_Textdomain_Registry { /** * List of domains and all their language directory paths for each locale. * * @since 6.1.0 * * @var array */ protected $all = array(); /** * List of domains and their language directory path for the current (most recent) locale. * * @since 6.1.0 * * @var array */ protected $current = array(); /** * List of domains and their custom language directory paths. * * @see load_plugin_textdomain() * @see load_theme_textdomain() * * @since 6.1.0 * * @var array */ protected $custom_paths = array(); /** * Holds a cached list of available .mo files to improve performance. * * @since 6.1.0 * @since 6.5.0 This property is no longer used. * * @var array * * @deprecated */ protected $cached_mo_files = array(); /** * Holds a cached list of domains with translations to improve performance. * * @since 6.2.0 * * @var string[] */ protected $domains_with_translations = array(); /** * Initializes the registry. * * Hooks into the {@see 'upgrader_process_complete'} filter * to invalidate MO files caches. * * @since 6.5.0 */ public function init() { add_action( 'upgrader_process_complete', array( $this, 'invalidate_mo_files_cache' ), 10, 2 ); } /** * Returns the languages directory path for a specific domain and locale. * * @since 6.1.0 * * @param string $domain Text domain. * @param string $locale Locale. * * @return string|false Languages directory path or false if there is none available. */ public function get( $domain, $locale ) { $path = $this->all[ $domain ][ $locale ] ?? $this->get_path_from_lang_dir( $domain, $locale ); /** * Filters the determined languages directory path for a specific domain and locale.Changelog
Introduced in 6.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-textdomain-registry.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.