PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.9.4
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.9.4
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 / Staging / FirstRun.php
wp-staging / Staging Last commit date
Ajax 1 year ago BackgroundProcessing 1 year ago Dto 1 year ago Interfaces 1 year ago Jobs 1 year ago Tasks 1 year ago Traits 1 year ago CloneOptions.php 1 year ago FirstRun.php 1 year ago Sites.php 1 year ago StagingServiceProvider.php 1 year ago
FirstRun.php
92 lines
1 <?php
2
3 namespace WPStaging\Staging;
4
5 use WPStaging\Frontend\LoginNotice;
6 use WPStaging\Framework\Notices\DisabledItemsNotice;
7 use WPStaging\Core\WPStaging;
8 use WPStaging\Framework\SiteInfo;
9 use WPStaging\Framework\ThirdParty\WordFence;
10 use WPStaging\Framework\ThirdParty\ThirdPartyCacheHandler;
11 use WPStaging\Framework\Filesystem\OPcache;
12
13 /**
14 * Class FirstRun
15 *
16 * This class is executed only on first run when the cloned site is loaded initially
17 *
18 * @package WPStaging\Staging
19 */
20 class FirstRun
21 {
22 /**
23 * The option_name that is stored in the database to check first run is executed or not
24 */
25 const FIRST_RUN_KEY = 'wpstg_execute';
26
27 /**
28 * The option_name that is stored in the database to check whether mails are disabled or not
29 */
30 const MAILS_DISABLED_KEY = 'wpstg_emails_disabled';
31
32 /** @var string */
33 const WOO_SCHEDULER_DISABLED_KEY = 'wpstg_woo_scheduler_disabled';
34
35 public function init()
36 {
37 if (!(new SiteInfo())->isStagingSite()) {
38 return;
39 }
40
41 if (!get_option(self::FIRST_RUN_KEY)) {
42 return;
43 }
44
45 $this->initActions();
46
47 $this->removeInitialRunOption();
48 }
49
50 /**
51 * Initialize actions and classes which can be hooked in by custom functions
52 * Add all classes here that you want to run on first time loading.
53 */
54 private function initActions()
55 {
56 // Show one time login notice on staging site.
57 (new LoginNotice())->setTransient();
58
59 // Enable the notice which show what WP Staging Disabled on staging site admin.
60 WPStaging::make(DisabledItemsNotice::class)->enable();
61
62 // Enable the notice which show what WP Staging Disabled on staging site admin.
63 // This notice is disabled at the moment. Code below can be uncommented and notice can be tweaked if needed later.
64 // WPStaging::make(WarningsNotice::class)->enable();
65
66 // If user.ini present rename it to user.ini.bak and enable notice
67 (new WordFence())->renameUserIni();
68
69 if (class_exists('\WPStaging\Pro\Staging\NetworkClone')) {
70 (new \WPStaging\Pro\Staging\NetworkClone())->init();
71 }
72
73 /** @var ThirdPartyCacheHandler $cacheHandler */
74 $cacheHandler = WPStaging::make(ThirdPartyCacheHandler::class);
75 $cacheHandler->purgeEnduranceCache();
76
77 // Allow users to attach custom actions by using this hook
78 do_action('wpstg.clone_first_run');
79
80 // Flush OPcache
81 WPStaging::make(OPcache::class)->maybeInvalidate();
82 }
83
84 /**
85 * Remove the first run flag from database
86 */
87 private function removeInitialRunOption()
88 {
89 delete_option(static::FIRST_RUN_KEY);
90 }
91 }
92