parser = $parser; $this->storage = $storage; $this->translatableWidgetsHook = $translatableWidgetsHook; } public function add_hooks() { add_filter( 'wpml_config_array', tap( [ $this, 'extractConfig' ] ) ); add_filter( $this->translatableWidgetsHook , [ $this, 'extendTranslatableWidgets' ], self::PRIORITY_AFTER_DEFAULT ); } public function extractConfig( array $allConfig ) { $this->storage->update( $this->parser->extract( $allConfig ) ); } /** * @param array $widgets * * @return array */ public function extendTranslatableWidgets( array $widgets ) { return array_merge( $widgets, $this->storage->get() ); } }