Ejemplo n.º 1
0
 /**
  * Return the site overwritten array of translations.
  * Use a "cache" ($array_i18n_overwritten) not to call get_option every time.
  *
  * @param $lang_code
  * 
  * @return array|null
  */
 private static function get_i18n_site_array($lang_code)
 {
     if (is_array(self::$array_i18n_overwritten)) {
         return self::$array_i18n_overwritten;
     }
     if (!is_string($json_i18n = get_option(self::SITE_I18N_OPTION, null)) || !is_array(self::$array_i18n_overwritten = json_decode($json_i18n, true)) || !is_array(self::$array_i18n_overwritten[$lang_code])) {
         if (!is_array($old_customized_translations = kigo_I18n::get_old_customized_translations($lang_code)) || !is_array($default_translations = self::get_default_translations($lang_code)) || !is_array(self::$array_i18n_overwritten[$lang_code] = array_diff_assoc($old_customized_translations, $default_translations)) || !self::update_i18n_customized_translation(self::$array_i18n_overwritten)) {
             // If something goes wrong in retrieving the old custom translations, let's consider there are none.
             // This is done not to trigger error when get entity textdata will be deprecated or on newly created sites.
             self::update_i18n_customized_translation(array($lang_code => array()));
             return array();
         }
         return self::$array_i18n_overwritten[$lang_code];
     }
     return self::$array_i18n_overwritten[$lang_code];
 }