default_lang_preset(); ?>

locale ) ) { $lang_code = $this->locale_to_lang_code( $current_user->locale ); } return $lang_code ? $lang_code : $def_lang; } /** * @return string */ private function default_lang_preset() { return $this->sitepress ->get_setting( 'existing_content_language_verified' ) ? $this->sitepress->get_default_language() : $this->def_lang_from_fallback(); } /** * @return string */ private function def_lang_from_fallback() { $blog_current_lang = 0; $wp_api = $this->sitepress->get_wp_api(); $wp_records = $this->sitepress->get_records(); if ( $blog_lang = $wp_api->get_option( 'WPLANG' ) ) { $blog_current_lang = $this->locale_to_lang_code( $blog_lang ); } if ( ! $blog_current_lang && ( $wp_lang_const = $wp_api->constant( 'WP_LANG' ) ) ) { $blog_current_lang = $wp_records->icl_languages_by_default_locale( $wp_lang_const )->code(); $blog_current_lang = $blog_current_lang ? $blog_current_lang : $this->locale_to_lang_code( $wp_lang_const ); } return $blog_current_lang ? $blog_current_lang : 'en'; } /** * @param string $locale * * @return false|string */ private function locale_to_lang_code( $locale ) { $exp = explode( '_', $locale ); return $exp[0] && $this->sitepress->get_records() ->icl_languages_by_code( $exp[0] )->exists() ? $exp[0] : false; } }