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