implementations = array_key_exists( 'interfaceMappings', $config ) ? $config['interfaceMappings'] : []; $this->hookHandlers = array_key_exists( 'hookHandlers', $config ) ? $config['hookHandlers'] : []; $this->settings = array_key_exists( 'settings', $config ) ? $config['settings'] : []; global $sitepress; global $wpdb; $filesystem = new \WP_Filesystem_Direct( null ); $this->injector = new Injector(); $this->injector->share( QueueRepositoryInterface::class ); $this->injector->share( LoadedTextdomainRepositoryInterface::class ); $this->injector->share( SettingsRepositoryInterface::class ); $this->injector->defineParam( 'sitepress', $sitepress ); $this->injector->defineParam( 'wpdb', $wpdb ); $this->injector->defineParam( 'filesystem', $filesystem ); foreach ( $this->implementations as $interfaceClass => $implementationClass ) { $this->injector->alias( $interfaceClass, $implementationClass ); } $this->injector->delegate( ProcessFrontendGettextStringsQueueInterface::class, function () use ( $sitepress ) { $translateEverythingObserver = new ProcessFrontendStringsObserver( ( new UntranslatedStringsFactory() )->create(), new Actions( new \WPML_Translation_Element_Factory( $sitepress, null ) ) ); return $this->injector->make( ProcessFrontendGettextStringsQueue::class, [ ':observers' => [ $translateEverythingObserver ] ] ); } ); $factory = new Factory( $this->injector ); $this->injector->share( $factory ); } public function run() { /** * @var SettingsRepositoryInterface $settingsRepository */ $settingsRepository = $this->injector->make( SettingsRepositoryInterface::class ); $ignoreIsDisabled = $this->settings['ignoreIsDisabled'] ?? false; $isDisabled = ( $settingsRepository->isAutoregisterStringsTypeDisabled() || $settingsRepository->shouldNotAutoregisterStringsFromCurrentUrl() ); foreach ( $this->hookHandlers as $hookHandler ) { $hookHandler = $this->injector->make( $hookHandler ); if ( $hookHandler instanceof HookHandlerInterface ) { if ( $isDisabled && ! $ignoreIsDisabled && $hookHandler instanceof AutoregisterHookInterface ) { continue; } $hookHandler->load(); } } } }