PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.10.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.10.0
4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Backup / AfterRestore.php
wp-staging / Backup Last commit date
Ajax 4 days ago BackgroundProcessing 1 year ago Dto 4 days ago Entity 2 weeks ago Exceptions 1 year ago FileHeader 2 months ago Interfaces 8 months ago Job 3 months ago Request 1 year ago Service 4 days ago Storage 2 months ago Task 4 days ago Traits 11 months ago Utils 1 week ago AfterRestore.php 6 months ago BackupDeleter.php 1 week ago BackupDownload.php 10 months ago BackupFileIndex.php 1 year ago BackupGlitchReason.php 1 year ago BackupHeader.php 2 months ago BackupNextOffer.php 4 days ago BackupRepairer.php 8 months ago BackupRetentionHandler.php 2 months ago BackupScheduler.php 4 days ago BackupServiceProvider.php 3 months ago BackupValidator.php 1 week ago FileHeader.php 1 month ago FileHeaderAttribute.php 2 years ago WithBackupIdentifier.php 1 week ago
AfterRestore.php
67 lines
1 <?php
2
3 namespace WPStaging\Backup;
4
5 use WPStaging\Backup\Service\Database\DatabaseImporter;
6 use WPStaging\Framework\Database\TableService;
7 use WPStaging\Framework\Facades\Hooks;
8 use WPStaging\Framework\Security\AccessToken;
9 use WPStaging\Framework\ThirdParty\NinjaForms;
10
11 class AfterRestore
12 {
13 /** @var string */
14 const FILTER_BACKUP_IMPORT_DATABASE_DROP_OLD_TABLES_AFTER_RESTORE = 'wpstg.backup.import.database.dropOldTablesAfterRestore';
15
16 /**
17 * @var TableService
18 */
19 protected $tableService;
20
21 /**
22 * @var AccessToken
23 */
24 protected $accessToken;
25
26 /**
27 * @var NinjaForms
28 */
29 protected $ninjaForms;
30
31 /**
32 * @param TableService $tableService
33 * @param AccessToken $accessToken
34 * @param NinjaForms $ninjaForms
35 */
36 public function __construct(TableService $tableService, AccessToken $accessToken, NinjaForms $ninjaForms)
37 {
38 $this->tableService = $tableService;
39 $this->accessToken = $accessToken;
40 $this->ninjaForms = $ninjaForms;
41 }
42
43 /**
44 * @action wp_login
45 * @see \WPStaging\Backup\BackupServiceProvider::addHooks
46 */
47 public function loginAfterRestore()
48 {
49 // Early bail: Not a login after a successful restore
50 if (get_option('wpstg.restore.justRestored') !== 'yes') {
51 return;
52 }
53
54 // Disable WordPress automatic background updates on this request.
55 add_filter('automatic_updater_disabled', '__return_false');
56
57 if (Hooks::applyFilters(self::FILTER_BACKUP_IMPORT_DATABASE_DROP_OLD_TABLES_AFTER_RESTORE, true)) {
58 $this->tableService->deleteTablesStartWith(DatabaseImporter::TMP_DATABASE_PREFIX_TO_DROP, [], true);
59 }
60
61 $this->ninjaForms->mayBeDisableMaintenanceMode();
62 $this->accessToken->generateNewToken();
63 delete_option('wpstg.restore.justRestored');
64 delete_option('wpstg.restore.justRestored.metadata');
65 }
66 }
67