manager = $file_manager; $this->domains = $domains; $this->loadedDictionary = $loadedDictionary; $this->syncMissingFile = $syncMissingFile ?: function () { }; } public function add_hooks() { $locale = get_locale(); $getDomainPathTuple = function ( $domain ) use ( $locale ) { return [ $domain, $this->manager->getFilepath( $domain, $locale ) ]; }; $isReadableFile = function ( $domainAndFilePath ) { return is_readable( $domainAndFilePath[1] ); }; $addJitMoToL10nGlobal = pipe( Lst::nth( 0 ), function ( $domain ) use ( $locale ) { $GLOBALS['l10n'][ $domain ] = new MO( $this->loadedDictionary, $locale, $domain ); } ); \wpml_collect( $this->domains->getCustomMODomains() ) ->map( $getDomainPathTuple ) ->each( spreadArgs( $this->syncMissingFile ) ) ->each( spreadArgs( [ $this->loadedDictionary, 'addFile' ] ) ) ->filter( $isReadableFile ) ->each( $addJitMoToL10nGlobal ); } }