wp-staging
Last commit date
Backend
1 year ago
Backup
1 year ago
Basic
2 years ago
Core
2 years ago
Duplicator
2 years ago
Framework
1 year ago
Frontend
2 years ago
Notifications
1 year ago
assets
1 year ago
languages
3 years ago
vendor_wpstg
1 year ago
CONTRIBUTING.md
2 years ago
Deactivate.php
2 years ago
README.md
2 years ago
SECURITY.md
2 years ago
autoloader.php
3 years ago
bootstrap.php
2 years ago
constantsFree.php
1 year ago
freeBootstrap.php
2 years ago
install.php
2 years ago
opcacheBootstrap.php
1 year ago
readme.txt
1 year ago
runtimeRequirements.php
2 years ago
uninstall.php
2 years ago
wp-staging-error-handler.php
2 years ago
wp-staging.php
1 year ago
freeBootstrap.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The purpose of the pre-bootstrap process is to make sure the environment is able to run |
| 5 | * the plugin without any errors, such as making sure there are no other WPSTAGING instances |
| 6 | * active at the same time. |
| 7 | * |
| 8 | * It works at a low level, without the autoloader, using anonymous callbacks and local variables |
| 9 | * to make sure we always use and execute the expected code. |
| 10 | * |
| 11 | * Since it uses closures, you can't dequeue those actions, but this is expected. |
| 12 | * |
| 13 | * @var string $pluginFilePath The absolute path to the main file of this plugin. |
| 14 | */ |
| 15 | |
| 16 | add_action('plugins_loaded', function () use ($pluginFilePath) { |
| 17 | // Unused $pluginFilePath: Other code will fail if removed it |
| 18 | try { |
| 19 | require __DIR__ . '/runtimeRequirements.php'; |
| 20 | require_once __DIR__ . '/bootstrap.php'; |
| 21 | } catch (Exception $e) { |
| 22 | if (defined('WPSTG_DEBUG') && WPSTG_DEBUG) { |
| 23 | error_log('WP STAGING: ' . $e->getMessage()); |
| 24 | } |
| 25 | } |
| 26 | }, 11, 0); // The priority of this hook must be larger than 10 for the runtime requirement check to detect older versions of WPSTAGING. |
| 27 | |
| 28 | register_activation_hook($pluginFilePath, function () use ($pluginFilePath) { |
| 29 | // Unused $pluginFilePath: Other code will fail if removed it |
| 30 | |
| 31 | try { |
| 32 | require __DIR__ . '/runtimeRequirements.php'; |
| 33 | require_once __DIR__ . '/bootstrap.php'; |
| 34 | require_once __DIR__ . '/install.php'; |
| 35 | } catch (Exception $e) { |
| 36 | if (defined('WPSTG_DEBUG') && WPSTG_DEBUG) { |
| 37 | error_log('WP STAGING: ' . $e->getMessage()); |
| 38 | } |
| 39 | } |
| 40 | }); |
| 41 | |
| 42 | register_deactivation_hook($pluginFilePath, function () use ($pluginFilePath) { |
| 43 | if (!class_exists('WPStaging\Deactivate')) { |
| 44 | require_once __DIR__ . '/Deactivate.php'; |
| 45 | } |
| 46 | |
| 47 | new WPStaging\Deactivate($pluginFilePath); |
| 48 | }); |
| 49 |