_load_textdomain_just_in_time

Loads plugin and theme textdomains just-in-time.

Description

_load_textdomain_just_in_time( (string) $domain ); 

When a textdomain is encountered for the first time, we try to load the translation file from wp-content/languages,, removing the need to call load_plugin_texdomain() or load_theme_texdomain().

Parameters (1)

0. $domain (string)
Text domain. Unique identifier for retrieving translated strings.

Usage

  1. if ( !function_exists( '_load_textdomain_just_in_time' ) ) { 
  2. require_once ABSPATH . WPINC . '/l10n.php'; 
  3.  
  4. // Text domain. Unique identifier for retrieving translated strings. 
  5. $domain = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _load_textdomain_just_in_time($domain); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/l10n.php  
  1. function _load_textdomain_just_in_time( $domain ) { 
  2. global $l10n_unloaded; 
  3.  
  4. $l10n_unloaded = (array) $l10n_unloaded; 
  5.  
  6. // Short-circuit if domain is 'default' which is reserved for core. 
  7. if ( 'default' === $domain || isset( $l10n_unloaded[ $domain ] ) ) { 
  8. return false; 
  9.  
  10. $translation_path = _get_path_to_translation( $domain ); 
  11. if ( false === $translation_path ) { 
  12. return false; 
  13.  
  14. return load_textdomain( $domain, $translation_path );