wp-staging
Last commit date
Backend
3 months ago
Backup
3 months ago
Basic
3 months ago
Component
6 months ago
Core
3 months ago
Framework
3 months ago
Frontend
5 months ago
Notifications
8 months ago
Staging
3 months ago
assets
3 months ago
languages
3 months ago
resources
1 year ago
vendor_wpstg
3 months ago
views
3 months ago
CONTRIBUTING.md
1 year ago
Deactivate.php
8 months ago
README.md
3 months ago
SECURITY.md
2 years ago
autoloader.php
6 months ago
bootstrap.php
9 months ago
constantsFree.php
3 months ago
freeBootstrap.php
1 year ago
install.php
1 year ago
opcacheBootstrap.php
3 months ago
readme.txt
3 months ago
runtimeRequirements.php
5 months ago
uninstall.php
3 months ago
wp-staging-error-handler.php
6 months ago
wp-staging.php
3 months ago
freeBootstrap.php
99 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 | add_action('plugins_loaded', function () use ($pluginFilePath) { |
| 42 | // Unused $pluginFilePath: Other code will fail if removed it |
| 43 | try { |
| 44 | $files = [ |
| 45 | __DIR__ . '/runtimeRequirements.php', |
| 46 | __DIR__ . '/bootstrap.php', |
| 47 | ]; |
| 48 | |
| 49 | foreach ($files as $file) { |
| 50 | if (file_exists($file)) { |
| 51 | require_once $file; |
| 52 | } else { |
| 53 | wpstgHandleMissingRequiredFile($file); |
| 54 | } |
| 55 | } |
| 56 | } catch (Exception $e) { |
| 57 | if (defined('WPSTG_DEBUG') && WPSTG_DEBUG) { |
| 58 | error_log('WP STAGING: ' . $e->getMessage()); |
| 59 | } |
| 60 | } |
| 61 | }, 11, 0); // The priority of this hook must be larger than 10 for the runtime requirement check to detect older versions of WPSTAGING. |
| 62 | |
| 63 | register_activation_hook($pluginFilePath, function () use ($pluginFilePath) { |
| 64 | // Unused $pluginFilePath: Other code will fail if removed it |
| 65 | |
| 66 | try { |
| 67 | $files = [ |
| 68 | __DIR__ . '/runtimeRequirements.php', |
| 69 | __DIR__ . '/bootstrap.php', |
| 70 | __DIR__ . '/install.php', |
| 71 | ]; |
| 72 | |
| 73 | foreach ($files as $file) { |
| 74 | if (file_exists($file)) { |
| 75 | require_once $file; |
| 76 | } else { |
| 77 | wpstgHandleMissingRequiredFile($file); |
| 78 | } |
| 79 | } |
| 80 | } catch (Exception $e) { |
| 81 | if (defined('WPSTG_DEBUG') && WPSTG_DEBUG) { |
| 82 | error_log('WP STAGING: ' . $e->getMessage()); |
| 83 | } |
| 84 | } |
| 85 | }); |
| 86 | |
| 87 | register_deactivation_hook($pluginFilePath, function () use ($pluginFilePath) { |
| 88 | if (!class_exists('WPStaging\Deactivate')) { |
| 89 | $file = __DIR__ . '/Deactivate.php'; |
| 90 | if (file_exists($file)) { |
| 91 | require_once $file; |
| 92 | } else { |
| 93 | wpstgHandleMissingRequiredFile($file); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | new WPStaging\Deactivate($pluginFilePath); |
| 98 | }); |
| 99 |