Cleaners
5 years ago
Exceptions
5 years ago
Cancel.php
2 years ago
CancelUpdate.php
2 years ago
Cloning.php
2 years ago
CloningProcess.php
2 years ago
Data.php
2 years ago
Database.php
2 years ago
Delete.php
2 years ago
Directories.php
2 years ago
Files.php
2 years ago
Finish.php
2 years ago
Job.php
2 years ago
JobExecutable.php
2 years ago
Logs.php
3 years ago
PreserveDataFirstStep.php
3 years ago
PreserveDataSecondStep.php
3 years ago
ProcessLock.php
2 years ago
Scan.php
2 years ago
SearchReplace.php
2 years ago
TotalStepsAreNumberOfTables.php
5 years ago
Updating.php
2 years ago
Data.php
86 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backend\Modules\Jobs; |
| 4 | |
| 5 | use WPStaging\Core\WPStaging; |
| 6 | use WPStaging\Framework\CloningProcess\Data\CleanThirdPartyConfigs; |
| 7 | use WPStaging\Framework\CloningProcess\Data\CopyWpConfig; |
| 8 | use WPStaging\Framework\CloningProcess\Data\Job as DataJob; |
| 9 | use WPStaging\Framework\CloningProcess\Data\MultisiteAddNetworkAdministrators; |
| 10 | use WPStaging\Framework\CloningProcess\Data\MultisiteUpdateActivePlugins; |
| 11 | use WPStaging\Framework\CloningProcess\Data\ResetIndexPhp; |
| 12 | use WPStaging\Framework\CloningProcess\Data\UpdateSiteUrlAndHome; |
| 13 | use WPStaging\Framework\CloningProcess\Data\UpdateTablePrefix; |
| 14 | use WPStaging\Framework\CloningProcess\Data\UpdateWpConfigConstants; |
| 15 | use WPStaging\Framework\CloningProcess\Data\UpdateWpConfigTablePrefix; |
| 16 | use WPStaging\Framework\CloningProcess\Data\UpdateWpOptionsTablePrefix; |
| 17 | use WPStaging\Framework\CloningProcess\Data\UpdateStagingOptionsTable; |
| 18 | use WPStaging\Framework\Utils\Strings; |
| 19 | |
| 20 | /** |
| 21 | * Class Data |
| 22 | * @package WPStaging\Backend\Modules\Jobs |
| 23 | */ |
| 24 | class Data extends DataJob |
| 25 | { |
| 26 | /** |
| 27 | * Initialize |
| 28 | */ |
| 29 | public function initialize() |
| 30 | { |
| 31 | parent::initialize(); |
| 32 | $this->getTables(); |
| 33 | } |
| 34 | |
| 35 | protected function initializeSteps() |
| 36 | { |
| 37 | $this->steps = [ |
| 38 | CopyWpConfig::class, // Copy wp-config.php from the staging site if it is located outside of root one level up or copy default wp-config.php if production site uses bedrock or any other boilerplate solution that stores wp default config data elsewhere. |
| 39 | UpdateSiteUrlAndHome::class, |
| 40 | UpdateStagingOptionsTable::class, |
| 41 | UpdateTablePrefix::class, |
| 42 | UpdateWpConfigTablePrefix::class, |
| 43 | ResetIndexPhp::class, // This is needed if live site is located in subfolder. @see: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory |
| 44 | UpdateWpOptionsTablePrefix::class, // This is important when custom folders are used |
| 45 | UpdateWpConfigConstants::class, |
| 46 | CleanThirdPartyConfigs::class, // Remove or use dummy config files for hosting like Flywheel etc |
| 47 | ]; |
| 48 | |
| 49 | if ($this->isMultisiteAndPro() && !$this->isNetworkClone()) { |
| 50 | $this->steps[] = MultisiteUpdateActivePlugins::class; // Merge sitewide active plugins and subsite active plugins |
| 51 | $this->steps[] = MultisiteAddNetworkAdministrators::class; // Add network administrators to _usermeta |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get a list of tables to copy |
| 57 | */ |
| 58 | protected function getTables() |
| 59 | { |
| 60 | $strings = new Strings(); |
| 61 | $this->tables = []; |
| 62 | foreach ($this->options->tables as $table) { |
| 63 | $this->tables[] = $this->options->prefix . $strings->str_replace_first(WPStaging::getTablePrefix(), null, $table); |
| 64 | } |
| 65 | |
| 66 | if ($this->isMultisiteAndPro() && !$this->isNetworkClone()) { |
| 67 | // Add extra global tables from main multisite (wpstg[x]_users and wpstg[x]_usermeta) |
| 68 | $this->tables[] = $this->options->prefix . 'users'; |
| 69 | $this->tables[] = $this->options->prefix . 'usermeta'; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Calculate total steps in this job and assign it to $this->options->totalSteps |
| 75 | * @return void |
| 76 | */ |
| 77 | protected function calculateTotalSteps() |
| 78 | { |
| 79 | $this->options->totalSteps = 8; |
| 80 | |
| 81 | if ($this->isMultisiteAndPro() && !$this->isNetworkClone()) { |
| 82 | $this->options->totalSteps = 10; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 |