Ajax
1 year ago
BackgroundProcessing
1 year ago
Dto
1 year ago
Entity
1 year ago
Exceptions
1 year ago
Interfaces
1 year ago
Job
1 year ago
Request
2 years ago
Service
1 year ago
Storage
2 years ago
Task
1 year ago
AfterRestore.php
1 year ago
BackupDeleter.php
1 year ago
BackupDownload.php
1 year ago
BackupFileIndex.php
1 year ago
BackupHeader.php
1 year ago
BackupRepairer.php
1 year ago
BackupRetentionHandler.php
2 years ago
BackupScheduler.php
1 year ago
BackupServiceProvider.php
1 year ago
BackupValidator.php
1 year ago
FileHeader.php
1 year ago
FileHeaderAttribute.php
2 years ago
WithBackupIdentifier.php
1 year ago
AfterRestore.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup; |
| 4 | |
| 5 | use WPStaging\Backup\Ajax\Restore\PrepareRestore; |
| 6 | use WPStaging\Framework\Database\TableService; |
| 7 | use WPStaging\Framework\Security\AccessToken; |
| 8 | use WPStaging\Framework\ThirdParty\NinjaForms; |
| 9 | |
| 10 | class AfterRestore |
| 11 | { |
| 12 | /** |
| 13 | * @var TableService |
| 14 | */ |
| 15 | protected $tableService; |
| 16 | |
| 17 | /** |
| 18 | * @var AccessToken |
| 19 | */ |
| 20 | protected $accessToken; |
| 21 | |
| 22 | /** |
| 23 | * @var NinjaForms |
| 24 | */ |
| 25 | protected $ninjaForms; |
| 26 | |
| 27 | /** |
| 28 | * @param TableService $tableService |
| 29 | * @param AccessToken $accessToken |
| 30 | * @param NinjaForms $ninjaForms |
| 31 | */ |
| 32 | public function __construct(TableService $tableService, AccessToken $accessToken, NinjaForms $ninjaForms) |
| 33 | { |
| 34 | $this->tableService = $tableService; |
| 35 | $this->accessToken = $accessToken; |
| 36 | $this->ninjaForms = $ninjaForms; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @action wp_login |
| 41 | * @see \WPStaging\Backup\BackupServiceProvider::addHooks |
| 42 | */ |
| 43 | public function loginAfterRestore() |
| 44 | { |
| 45 | // Early bail: Not a login after a successful restore |
| 46 | if (get_option('wpstg.restore.justRestored') !== 'yes') { |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | // Disable WordPress automatic background updates on this request. |
| 51 | add_filter('automatic_updater_disabled', '__return_false'); |
| 52 | |
| 53 | if (apply_filters('wpstg.backup.import.database.dropOldTablesAfterRestore', true)) { |
| 54 | $this->tableService->deleteTablesStartWith(PrepareRestore::TMP_DATABASE_PREFIX_TO_DROP, [], true); |
| 55 | } |
| 56 | |
| 57 | $this->ninjaForms->mayBeDisableMaintenanceMode(); |
| 58 | $this->accessToken->generateNewToken(); |
| 59 | delete_option('wpstg.restore.justRestored'); |
| 60 | delete_option('wpstg.restore.justRestored.metadata'); |
| 61 | } |
| 62 | } |
| 63 |