PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.0
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 / freeBootstrap.php
wp-staging Last commit date
Backend 1 week ago Backup 1 week ago Basic 1 week ago Component 1 week ago Core 1 week ago Framework 1 week ago Frontend 5 months ago Notifications 8 months ago Staging 1 week ago assets 1 week ago languages 1 week ago resources 1 year ago vendor_wpstg 1 week ago views 1 week ago CONTRIBUTING.md 1 year ago Deactivate.php 8 months ago README.md 3 months ago SECURITY.md 2 years ago autoloader.php 1 month ago bootstrap.php 1 month ago commonBootstrap.php 1 week ago constantsFree.php 1 week ago freeBootstrap.php 1 month ago install.php 1 week ago opcacheBootstrap.php 1 week ago readme.txt 1 week ago runtimeRequirements.php 3 months ago uninstall.php 1 week ago wp-staging-error-handler.php 6 months ago wp-staging.php 1 week ago
freeBootstrap.php
119 lines
1 <?php
2
3 if (!function_exists('wpstgHandleMissingRequiredFile')) {
4 /**
5 * @param string $filePath
6 */
7 function wpstgHandleMissingRequiredFile(string $filePath)
8 {
9 $errorMessage = sprintf("WP STAGING WARNING: Attempted to require missing file: %s.", esc_html($filePath));
10 if (defined('WPSTG_DEBUG') && (bool)WPSTG_DEBUG) {
11 error_log($errorMessage);
12 }
13
14 if (defined('WPSTGPRO_VERSION')) {
15 return;
16 }
17
18 add_action('admin_notices', function () use ($errorMessage) {
19 $errorMessage = "$errorMessage Please contact support@wp-staging.com for help!";
20 echo '<div class="notice notice-error is-dismissible"><p>' . esc_html($errorMessage) . '</p></div>';
21 });
22
23 return;
24 }
25 }
26
27 /**
28 * The purpose of the pre-bootstrap process is to make sure the environment is able to run
29 * the plugin without any errors, such as making sure there are no other WPSTAGING instances
30 * active at the same time.
31 *
32 * It works at a low level, without the autoloader, using anonymous callbacks and local variables
33 * to make sure we always use and execute the expected code.
34 *
35 * Since it uses closures, you can't dequeue those actions, but this is expected.
36 *
37 * @var string $pluginFilePath The absolute path to the main file of this plugin.
38 */
39 $pluginFilePath = empty($pluginFilePath) ? '' : $pluginFilePath;
40
41 require_once __DIR__ . '/commonBootstrap.php';
42
43 add_action('plugins_loaded', function () use ($pluginFilePath) {
44 // Unused $pluginFilePath: Other code will fail if removed it
45 if (wpstgShouldSkipBootstrap()) {
46 return;
47 }
48
49 try {
50 $files = [
51 __DIR__ . '/runtimeRequirements.php',
52 __DIR__ . '/bootstrap.php',
53 ];
54
55 foreach ($files as $file) {
56 if (file_exists($file)) {
57 require_once $file;
58 } else {
59 wpstgHandleMissingRequiredFile($file);
60 }
61 }
62 } catch (\Throwable $e) {
63 // Catch \Throwable (not just Exception) so PHP 7+ Errors like
64 // "Class not found" cannot escape this safety net and crash WordPress.
65 // Issue #5074.
66 if (defined('WPSTG_DEBUG') && WPSTG_DEBUG) {
67 error_log('WP STAGING: ' . $e->getMessage());
68 }
69 }
70 }, 11, 0); // The priority of this hook must be larger than 10 for the runtime requirement check to detect older versions of WPSTAGING.
71
72 register_activation_hook($pluginFilePath, function () use ($pluginFilePath) {
73 // Unused $pluginFilePath: Other code will fail if removed it
74
75 try {
76 $files = [
77 __DIR__ . '/runtimeRequirements.php',
78 __DIR__ . '/bootstrap.php',
79 __DIR__ . '/install.php',
80 ];
81
82 foreach ($files as $file) {
83 if (file_exists($file)) {
84 require_once $file;
85 } else {
86 wpstgHandleMissingRequiredFile($file);
87 }
88 }
89 } catch (\Throwable $e) {
90 // Catch \Throwable (not just Exception) so PHP 7+ Errors like
91 // "Class not found" cannot escape this safety net and crash WordPress.
92 // Issue #5074.
93 if (defined('WPSTG_DEBUG') && WPSTG_DEBUG) {
94 error_log('WP STAGING: ' . $e->getMessage());
95 }
96 }
97 });
98
99 register_deactivation_hook($pluginFilePath, function () use ($pluginFilePath) {
100 if (!class_exists('WPStaging\Deactivate')) {
101 $file = __DIR__ . '/Deactivate.php';
102 if (file_exists($file)) {
103 require_once $file;
104 } else {
105 wpstgHandleMissingRequiredFile($file);
106 }
107 }
108
109 try {
110 new WPStaging\Deactivate($pluginFilePath);
111 } catch (\Throwable $e) {
112 // Swallow: deactivation must succeed even if internal cleanup fails (corrupted vendor state).
113 if (defined('WPSTG_DEBUG') && WPSTG_DEBUG) {
114 error_log('WP STAGING: Deactivation cleanup failed: ' . $e->getMessage());
115 error_log($e->getTraceAsString());
116 }
117 }
118 });
119