then( [ self::class, 'getData' ] ) ->then( Resources::enqueueApp( 'icl-to-ate-migration' ) ); } } /** * @return bool */ public static function shouldShowMigration() { // TODO: Remove wpml_is_ajax condition once wpmltm-4351 is done. // phpcs:disable // This feature is disabled by default now. See wpmldev-857. if ( ! defined( 'WPML_ICL_ATE_MIGRATION_ENABLED' ) || ! WPML_ICL_ATE_MIGRATION_ENABLED ) { return false; } return ! wpml_is_ajax() && UIPage::isTroubleshooting( $_GET ) && ( isset( $_GET['icl-to-ate'] ) || make(ICLStatus::class)->isActivatedAndAuthorized() || Data::isICLDeactivated() ); // phpcs:enable } public static function renderContainerIfNeeded() { if ( self::shouldShowMigration() ) { return '
'; } return ''; } public static function getData() { $originalLanguageCode = Languages::getDefaultCode(); $userLanguageCode = Languages::getUserLanguageCode()->getOrElse( $originalLanguageCode ); return [ 'name' => 'wpmlIclToAteMigration', 'data' => [ 'endpoints' => [ 'GetTranslatorsFromICL' => GetFromICL::class, 'StartImportTranslationMemory' => StartMigration::class, 'CheckImportTranslationMemoryProgress' => CheckMigrationStatus::class, 'SaveTranslators' => Save::class, 'AuthenticateICL' => AuthenticateICL::class, 'DeactivateICL' => DeactivateICL::class, ], 'languages' => [ 'list' => Obj::values( Languages::withFlags( Languages::getAll( $userLanguageCode ) ) ), 'secondaries' => Languages::getSecondaryCodes(), 'original' => $originalLanguageCode, ], 'isICLActive' => make( ICLStatus::class )->isActivatedAndAuthorized(), 'migrationsDone' => [ 'memory' => Data::isMemoryMigrated(), ], 'ICLDeactivated' => Data::isICLDeactivated(), ], ]; } }