Version Description
- Fix: Fatal error on activation if PHP version < 7.x version on some circumstances
Download this release
Release Info
Developer | ReneHermi |
Plugin | WP Staging – DB & File Duplicator & Migration |
Version | 2.7.7 |
Comparing to | |
See all releases |
Code changes from version 2.7.6 to 2.7.7
- Backend/Activation/Activation.php +0 -45
- Backend/Administrator.php +36 -42
- Backend/Notices/Notices.php +0 -29
- Backend/public/js/wpstg-admin.js +2 -1
- Core/Utils/Loader.php +0 -71
- Core/WPStaging.php +3 -15
- Framework/AbstractPlugin.php +0 -7
- Framework/Adapter/Dto/HookDto.php +0 -103
- Framework/Adapter/HookedTemplate.php +8 -13
- Framework/Adapter/Hooks.php +0 -47
- Framework/Component/AbstractComponent.php +1 -53
- Framework/Component/AbstractTemplateComponent.php +1 -1
- Framework/Database/DatabaseRestore.php +1 -1
- Framework/Filesystem/Filesystem.php +2 -2
- Frontend/Frontend.php +3 -5
- Requirements/WpstgFreeRequirements.php +159 -0
- Requirements/WpstgRequirements.php +34 -0
- _init.php +3 -16
- constants.php +1 -1
- readme.txt +4 -1
- vendor/composer/autoload_classmap.php +0 -4
- vendor/composer/autoload_static.php +0 -4
- wp-staging.php +54 -8
Backend/Activation/Activation.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WPStaging\Backend\Activation;
|
4 |
-
|
5 |
-
// No Direct Access
|
6 |
-
if (!defined("WPINC")) {
|
7 |
-
die;
|
8 |
-
}
|
9 |
-
|
10 |
-
class Activation
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Checks if another version of WPSTG (Pro) is active and deactivates it.
|
15 |
-
* To be hooked on `activated_plugin` so other plugin is deactivated when current plugin is activated.
|
16 |
-
*
|
17 |
-
* @param string $plugin
|
18 |
-
*
|
19 |
-
*/
|
20 |
-
public static function deactivate_other_instances($plugin)
|
21 |
-
{
|
22 |
-
if (!in_array(basename($plugin), array('wp-staging-pro.php', 'wp-staging.php'))) {
|
23 |
-
return;
|
24 |
-
}
|
25 |
-
$plugin_to_deactivate = 'wp-staging.php';
|
26 |
-
$deactivated_notice_id = '1';
|
27 |
-
if (basename($plugin) == $plugin_to_deactivate) {
|
28 |
-
$plugin_to_deactivate = 'wp-staging-pro.php';
|
29 |
-
$deactivated_notice_id = '2';
|
30 |
-
}
|
31 |
-
if (is_multisite()) {
|
32 |
-
$active_plugins = ( array )get_site_option('active_sitewide_plugins', array());
|
33 |
-
$active_plugins = array_keys($active_plugins);
|
34 |
-
} else {
|
35 |
-
$active_plugins = ( array )get_option('active_plugins', array());
|
36 |
-
}
|
37 |
-
foreach ($active_plugins as $basename) {
|
38 |
-
if (false !== strpos($basename, $plugin_to_deactivate)) {
|
39 |
-
set_transient('wp_staging_deactivated_notice_id', $deactivated_notice_id, 1 * HOUR_IN_SECONDS);
|
40 |
-
deactivate_plugins($basename);
|
41 |
-
return;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Backend/Administrator.php
CHANGED
@@ -109,61 +109,55 @@ class Administrator extends InjectionAware
|
|
109 |
*/
|
110 |
private function defineHooks()
|
111 |
{
|
112 |
-
// Get loader
|
113 |
-
$loader = $this->di->get("loader");
|
114 |
-
|
115 |
-
$Activation = new Activation\Activation();
|
116 |
-
|
117 |
if (!defined('WPSTGPRO_VERSION')) {
|
118 |
$Welcome = new Activation\Welcome();
|
119 |
}
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$loader->addAction("admin_notices", $this, "messages");
|
129 |
|
130 |
if (!defined('WPSTGPRO_VERSION')) {
|
131 |
add_filter('admin_footer', array($this, 'loadFeedbackForm'));
|
132 |
}
|
133 |
|
134 |
// Ajax Requests
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
|
161 |
// Ajax hooks pro Version
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
}
|
168 |
|
169 |
/**
|
109 |
*/
|
110 |
private function defineHooks()
|
111 |
{
|
|
|
|
|
|
|
|
|
|
|
112 |
if (!defined('WPSTGPRO_VERSION')) {
|
113 |
$Welcome = new Activation\Welcome();
|
114 |
}
|
115 |
|
116 |
+
add_action("admin_menu", [$this, "addMenu"], 10);
|
117 |
+
add_action("admin_init", [$this, "setOptionFormElements"]);
|
118 |
+
add_action("admin_init", [$this, "upgrade"]);
|
119 |
+
add_action("admin_post_wpstg_download_sysinfo", [$this, "systemInfoDownload"]);
|
120 |
+
add_action("admin_post_wpstg_export", [$this, "export"]);
|
121 |
+
add_action("admin_post_wpstg_import_settings", [$this, "import"]);
|
122 |
+
add_action("admin_notices", [$this, "messages"]);
|
|
|
123 |
|
124 |
if (!defined('WPSTGPRO_VERSION')) {
|
125 |
add_filter('admin_footer', array($this, 'loadFeedbackForm'));
|
126 |
}
|
127 |
|
128 |
// Ajax Requests
|
129 |
+
add_action("wp_ajax_wpstg_overview", [$this, "ajaxOverview"]);
|
130 |
+
add_action("wp_ajax_wpstg_scanning", [$this, "ajaxCloneScan"]);
|
131 |
+
add_action("wp_ajax_wpstg_check_clone", [$this, "ajaxcheckCloneName"]);
|
132 |
+
add_action("wp_ajax_wpstg_restart", [$this, "ajaxRestart"]);
|
133 |
+
add_action("wp_ajax_wpstg_update", [$this, "ajaxUpdateProcess"]);
|
134 |
+
add_action("wp_ajax_wpstg_cloning", [$this, "ajaxStartClone"]);
|
135 |
+
add_action("wp_ajax_wpstg_processing", [$this, "ajaxCloneDatabase"]);
|
136 |
+
add_action("wp_ajax_wpstg_database_connect", [$this, "ajaxDatabaseConnect"]);
|
137 |
+
add_action("wp_ajax_wpstg_clone_prepare_directories", [$this, "ajaxPrepareDirectories"]);
|
138 |
+
add_action("wp_ajax_wpstg_clone_files", [$this, "ajaxCopyFiles"]);
|
139 |
+
add_action("wp_ajax_wpstg_clone_replace_data", [$this, "ajaxReplaceData"]);
|
140 |
+
add_action("wp_ajax_wpstg_clone_finish", [$this, "ajaxFinish"]);
|
141 |
+
add_action("wp_ajax_wpstg_confirm_delete_clone", [$this, "ajaxDeleteConfirmation"]);
|
142 |
+
add_action("wp_ajax_wpstg_delete_clone", [$this, "ajaxDeleteClone"]);
|
143 |
+
add_action("wp_ajax_wpstg_cancel_clone", [$this, "ajaxCancelClone"]);
|
144 |
+
add_action("wp_ajax_wpstg_cancel_update", [$this, "ajaxCancelUpdate"]);
|
145 |
+
add_action("wp_ajax_wpstg_hide_poll", [$this, "ajaxHidePoll"]);
|
146 |
+
add_action("wp_ajax_wpstg_hide_rating", [$this, "ajaxHideRating"]);
|
147 |
+
add_action("wp_ajax_wpstg_hide_later", [$this, "ajaxHideLaterRating"]);
|
148 |
+
add_action("wp_ajax_wpstg_hide_beta", [$this, "ajaxHideBeta"]);
|
149 |
+
add_action("wp_ajax_wpstg_logs", [$this, "ajaxLogs"]);
|
150 |
+
add_action("wp_ajax_wpstg_check_disk_space", [$this, "ajaxCheckFreeSpace"]);
|
151 |
+
add_action("wp_ajax_wpstg_send_report", [$this, "ajaxSendReport"]);
|
152 |
+
add_action("wp_ajax_wpstg_send_feedback", [$this, "sendFeedback"]);
|
153 |
|
154 |
|
155 |
// Ajax hooks pro Version
|
156 |
+
add_action("wp_ajax_wpstg_edit_clone_data", [$this, "ajaxEditCloneData"]);
|
157 |
+
add_action("wp_ajax_wpstg_save_clone_data", [$this, "ajaxSaveCloneData"]);
|
158 |
+
add_action("wp_ajax_wpstg_scan", [$this, "ajaxPushScan"]);
|
159 |
+
add_action("wp_ajax_wpstg_push_processing", [$this, "ajaxPushProcessing"]);
|
160 |
+
add_action("wp_ajax_nopriv_wpstg_push_processing", [$this, "ajaxPushProcessing"]);
|
161 |
}
|
162 |
|
163 |
/**
|
Backend/Notices/Notices.php
CHANGED
@@ -114,9 +114,6 @@ class Notices {
|
|
114 |
|
115 |
$viewsNoticesPath = "{$this->path}views/notices/";
|
116 |
|
117 |
-
// Free and pro version have been activated at the same time
|
118 |
-
$this->plugin_deactivated_notice();
|
119 |
-
|
120 |
// Show "rate the plugin". Free version only
|
121 |
if (!defined('WPSTGPRO_VERSION')) {
|
122 |
if ($this->canShow("wpstg_rating", 7) && $this->getCurrentScreen() !== 'page' && $this->getCurrentScreen() !== 'post') {
|
@@ -157,12 +154,6 @@ class Notices {
|
|
157 |
require_once "{$viewsNoticesPath}beta.php";
|
158 |
}*/
|
159 |
|
160 |
-
// WP Staging Pro and Free can not be activated both
|
161 |
-
if( false !== ( $deactivatedNoticeID = get_transient( "wp_staging_deactivated_notice_id" ) ) ) {
|
162 |
-
require_once "{$viewsNoticesPath}transient.php";
|
163 |
-
delete_transient( "wp_staging_deactivated_notice_id" );
|
164 |
-
}
|
165 |
-
|
166 |
// Different scheme in home and siteurl
|
167 |
if( $this->isDifferentScheme() ) {
|
168 |
require_once "{$viewsNoticesPath}wrong-scheme.php";
|
@@ -183,24 +174,4 @@ class Notices {
|
|
183 |
return true;
|
184 |
}
|
185 |
|
186 |
-
/**
|
187 |
-
* Show a message when pro or free plugin becomes deactivated
|
188 |
-
*
|
189 |
-
* @return void
|
190 |
-
*/
|
191 |
-
private function plugin_deactivated_notice() {
|
192 |
-
if( false !== ( $deactivated_notice_id = get_transient( 'wp_staging_deactivated_notice_id' ) ) ) {
|
193 |
-
if( '1' === $deactivated_notice_id ) {
|
194 |
-
$message = __( "WP Staging and WP Staging Pro cannot both be active. We've automatically deactivated WP Staging.", 'wp-staging' );
|
195 |
-
} else {
|
196 |
-
$message = __( "WP Staging and WP Staging Pro cannot both be active. We've automatically deactivated WP Staging Pro.", 'wp-staging' );
|
197 |
-
}
|
198 |
-
?>
|
199 |
-
<div class="updated notice is-dismissible" style="border-left: 4px solid #ffba00;">
|
200 |
-
<p><?php echo esc_html( $message ); ?></p>
|
201 |
-
</div> <?php
|
202 |
-
delete_transient( 'wp_staging_deactivated_notice_id' );
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
}
|
114 |
|
115 |
$viewsNoticesPath = "{$this->path}views/notices/";
|
116 |
|
|
|
|
|
|
|
117 |
// Show "rate the plugin". Free version only
|
118 |
if (!defined('WPSTGPRO_VERSION')) {
|
119 |
if ($this->canShow("wpstg_rating", 7) && $this->getCurrentScreen() !== 'page' && $this->getCurrentScreen() !== 'post') {
|
154 |
require_once "{$viewsNoticesPath}beta.php";
|
155 |
}*/
|
156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
// Different scheme in home and siteurl
|
158 |
if( $this->isDifferentScheme() ) {
|
159 |
require_once "{$viewsNoticesPath}wrong-scheme.php";
|
174 |
return true;
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
}
|
Backend/public/js/wpstg-admin.js
CHANGED
@@ -485,7 +485,8 @@ var WPStaging = (function ($) {
|
|
485 |
}
|
486 |
|
487 |
$workFlow.removeClass("loading").html(response);
|
488 |
-
|
|
|
489 |
that.switchStep(2);
|
490 |
},
|
491 |
"HTML"
|
485 |
}
|
486 |
|
487 |
$workFlow.removeClass("loading").html(response);
|
488 |
+
// register check disk space function for clone update process.
|
489 |
+
checkDiskSpace();
|
490 |
that.switchStep(2);
|
491 |
},
|
492 |
"HTML"
|
Core/Utils/Loader.php
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace WPStaging\Utils;
|
3 |
-
|
4 |
-
// No Direct Access
|
5 |
-
if (!defined("WPINC"))
|
6 |
-
{
|
7 |
-
die;
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Loader
|
12 |
-
* @package WPStaging\Utils
|
13 |
-
*/
|
14 |
-
final class Loader
|
15 |
-
{
|
16 |
-
private $actions = array();
|
17 |
-
|
18 |
-
private $filters = array();
|
19 |
-
|
20 |
-
public function addAction($hook, $component, $callback, $priority = 10, $acceptedArgs = 1)
|
21 |
-
{
|
22 |
-
$this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $acceptedArgs);
|
23 |
-
}
|
24 |
-
|
25 |
-
public function addFilter($hook, $component, $callback, $priority = 10, $acceptedArgs = 1)
|
26 |
-
{
|
27 |
-
$this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $acceptedArgs);
|
28 |
-
}
|
29 |
-
|
30 |
-
private function add($hooks, $hook, $component, $callback, $priority = 10, $acceptedArgs = 1)
|
31 |
-
{
|
32 |
-
$hooks[] = array(
|
33 |
-
"hook" => $hook,
|
34 |
-
"component" => $component,
|
35 |
-
"callback" => $callback,
|
36 |
-
"priority" => $priority,
|
37 |
-
"acceptedArgs" => $acceptedArgs
|
38 |
-
);
|
39 |
-
|
40 |
-
return $hooks;
|
41 |
-
}
|
42 |
-
|
43 |
-
public function run($emptyAfterRun = true)
|
44 |
-
{
|
45 |
-
// Filters
|
46 |
-
foreach ($this->filters as $key => $hook)
|
47 |
-
{
|
48 |
-
add_filter(
|
49 |
-
$hook["hook"], array($hook["component"], $hook["callback"]), $hook["priority"], $hook["acceptedArgs"]
|
50 |
-
);
|
51 |
-
|
52 |
-
if (true === $emptyAfterRun)
|
53 |
-
{
|
54 |
-
unset($this->filters[$key]);
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
// Actions
|
59 |
-
foreach ($this->actions as $key => $hook)
|
60 |
-
{
|
61 |
-
add_action(
|
62 |
-
$hook["hook"], array($hook["component"], $hook["callback"]), $hook["priority"], $hook["acceptedArgs"]
|
63 |
-
);
|
64 |
-
|
65 |
-
if (true === $emptyAfterRun)
|
66 |
-
{
|
67 |
-
unset($this->actions[$key]);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Core/WPStaging.php
CHANGED
@@ -17,7 +17,6 @@ use WPStaging\Frontend\Frontend;
|
|
17 |
use WPStaging\Framework\Container\Container;
|
18 |
use WPStaging\Utils\Autoloader;
|
19 |
use WPStaging\Utils\Cache;
|
20 |
-
use WPStaging\Utils\Loader;
|
21 |
use WPStaging\Utils\Logger;
|
22 |
use WPStaging\Framework\PluginFactory;
|
23 |
use WPStaging\Framework\Permalinks\PermalinksPurge;
|
@@ -148,10 +147,9 @@ final class WPStaging {
|
|
148 |
* Define Hooks
|
149 |
*/
|
150 |
public function defineHooks() {
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
$loader->addAction( "wp_enqueue_scripts", $this, "enqueueElements", 100 );
|
155 |
}
|
156 |
|
157 |
/**
|
@@ -339,8 +337,6 @@ final class WPStaging {
|
|
339 |
// Load globally available functions
|
340 |
require_once ($this->pluginPath . "Core/Utils/functions.php");
|
341 |
|
342 |
-
$this->set( "loader", new Loader() );
|
343 |
-
|
344 |
$this->set( "cache", new Cache() );
|
345 |
|
346 |
$this->set( "logger", new Logger() );
|
@@ -360,14 +356,6 @@ final class WPStaging {
|
|
360 |
}
|
361 |
}
|
362 |
|
363 |
-
/**
|
364 |
-
* Execute Plugin
|
365 |
-
*/
|
366 |
-
public function run() {
|
367 |
-
/** @noinspection **/
|
368 |
-
$this->get( "loader" )->run();
|
369 |
-
}
|
370 |
-
|
371 |
/**
|
372 |
* Set a variable to DI with given name
|
373 |
* @param string $name
|
17 |
use WPStaging\Framework\Container\Container;
|
18 |
use WPStaging\Utils\Autoloader;
|
19 |
use WPStaging\Utils\Cache;
|
|
|
20 |
use WPStaging\Utils\Logger;
|
21 |
use WPStaging\Framework\PluginFactory;
|
22 |
use WPStaging\Framework\Permalinks\PermalinksPurge;
|
147 |
* Define Hooks
|
148 |
*/
|
149 |
public function defineHooks() {
|
150 |
+
add_action('admin_enqueue_scripts', [$this, 'enqueueElements'], 100);
|
151 |
+
add_action('admin_enqueue_scripts', [$this, 'removeWPCoreJs'], 5);
|
152 |
+
add_action('wp_enqueue_scripts', [$this, 'enqueueElements'], 100);
|
|
|
153 |
}
|
154 |
|
155 |
/**
|
337 |
// Load globally available functions
|
338 |
require_once ($this->pluginPath . "Core/Utils/functions.php");
|
339 |
|
|
|
|
|
340 |
$this->set( "cache", new Cache() );
|
341 |
|
342 |
$this->set( "logger", new Logger() );
|
356 |
}
|
357 |
}
|
358 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
/**
|
360 |
* Set a variable to DI with given name
|
361 |
* @param string $name
|
Framework/AbstractPlugin.php
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
namespace WPStaging\Framework;
|
4 |
|
5 |
use WPStaging\Framework\Adapter\Directory;
|
6 |
-
use WPStaging\Framework\Adapter\Hooks;
|
7 |
use WPStaging\Framework\Container\Container;
|
8 |
use WPStaging\WPStaging;
|
9 |
|
@@ -47,14 +46,9 @@ abstract class AbstractPlugin implements PluginInterface
|
|
47 |
$this->registerLifeCycle();
|
48 |
$this->loadLanguages();
|
49 |
|
50 |
-
/** @var Hooks $hooks */
|
51 |
-
$hooks = $this->container->get(Hooks::class);
|
52 |
-
|
53 |
foreach ($this->components as $id => $options) {
|
54 |
$this->container->setInitialized($id, $options);
|
55 |
}
|
56 |
-
|
57 |
-
$hooks->init();
|
58 |
}
|
59 |
|
60 |
/**
|
@@ -158,7 +152,6 @@ abstract class AbstractPlugin implements PluginInterface
|
|
158 |
|
159 |
private function initDependencies()
|
160 |
{
|
161 |
-
$this->container->set(Hooks::class, new Hooks);
|
162 |
$this->container->set(Directory::class, new Directory($this->getDomain(), $this->getSlug()));
|
163 |
$this->container->set(PluginInfo::class, new PluginInfo(
|
164 |
$this->getVersion(), $this->getSlug(), $this->getDomain()
|
3 |
namespace WPStaging\Framework;
|
4 |
|
5 |
use WPStaging\Framework\Adapter\Directory;
|
|
|
6 |
use WPStaging\Framework\Container\Container;
|
7 |
use WPStaging\WPStaging;
|
8 |
|
46 |
$this->registerLifeCycle();
|
47 |
$this->loadLanguages();
|
48 |
|
|
|
|
|
|
|
49 |
foreach ($this->components as $id => $options) {
|
50 |
$this->container->setInitialized($id, $options);
|
51 |
}
|
|
|
|
|
52 |
}
|
53 |
|
54 |
/**
|
152 |
|
153 |
private function initDependencies()
|
154 |
{
|
|
|
155 |
$this->container->set(Directory::class, new Directory($this->getDomain(), $this->getSlug()));
|
156 |
$this->container->set(PluginInfo::class, new PluginInfo(
|
157 |
$this->getVersion(), $this->getSlug(), $this->getDomain()
|
Framework/Adapter/Dto/HookDto.php
DELETED
@@ -1,103 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WPStaging\Framework\Adapter\Dto;
|
4 |
-
|
5 |
-
class HookDto
|
6 |
-
{
|
7 |
-
const DEFAULT_PRIORITY = 10;
|
8 |
-
|
9 |
-
/** @var string */
|
10 |
-
private $hook;
|
11 |
-
|
12 |
-
/** @var object */
|
13 |
-
private $component;
|
14 |
-
|
15 |
-
/** @var string */
|
16 |
-
private $callback;
|
17 |
-
|
18 |
-
/** @var int */
|
19 |
-
private $priority = 10;
|
20 |
-
|
21 |
-
/** @var int */
|
22 |
-
private $acceptedArgs = 0;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @return string|null
|
26 |
-
*/
|
27 |
-
public function getHook()
|
28 |
-
{
|
29 |
-
return $this->hook;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param string $hook
|
34 |
-
*/
|
35 |
-
public function setHook($hook)
|
36 |
-
{
|
37 |
-
$this->hook = $hook;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @return object|null
|
42 |
-
*/
|
43 |
-
public function getComponent()
|
44 |
-
{
|
45 |
-
return $this->component;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @param object $component
|
50 |
-
*/
|
51 |
-
public function setComponent($component)
|
52 |
-
{
|
53 |
-
$this->component = $component;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @return string|null
|
58 |
-
*/
|
59 |
-
public function getCallback()
|
60 |
-
{
|
61 |
-
return $this->callback;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* @param string $callback
|
66 |
-
*/
|
67 |
-
public function setCallback($callback)
|
68 |
-
{
|
69 |
-
$this->callback = $callback;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @return int
|
74 |
-
*/
|
75 |
-
public function getPriority()
|
76 |
-
{
|
77 |
-
return $this->priority?: self::DEFAULT_PRIORITY;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* @param int $priority
|
82 |
-
*/
|
83 |
-
public function setPriority($priority)
|
84 |
-
{
|
85 |
-
$this->priority = $priority;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* @return int
|
90 |
-
*/
|
91 |
-
public function getAcceptedArgs()
|
92 |
-
{
|
93 |
-
return (int)$this->acceptedArgs;
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* @param $acceptedArgs
|
98 |
-
*/
|
99 |
-
public function setAcceptedArgs($acceptedArgs)
|
100 |
-
{
|
101 |
-
$this->acceptedArgs = $acceptedArgs;
|
102 |
-
}
|
103 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Framework/Adapter/HookedTemplate.php
CHANGED
@@ -4,29 +4,24 @@ namespace WPStaging\Framework\Adapter;
|
|
4 |
|
5 |
use WPStaging\Framework\TemplateEngine\TemplateEngine;
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
class HookedTemplate
|
8 |
{
|
9 |
|
10 |
-
/** @var Hooks */
|
11 |
-
private $hooks;
|
12 |
-
|
13 |
/** @var TemplateEngine */
|
14 |
private $templateEngine;
|
15 |
|
16 |
-
public function __construct(
|
17 |
{
|
18 |
-
$this->hooks = $hooks;
|
19 |
$this->templateEngine = $templateEngine;
|
20 |
}
|
21 |
|
22 |
-
/**
|
23 |
-
* @return Hooks
|
24 |
-
*/
|
25 |
-
public function getHooks()
|
26 |
-
{
|
27 |
-
return $this->hooks;
|
28 |
-
}
|
29 |
-
|
30 |
/**
|
31 |
* @return TemplateEngine
|
32 |
*/
|
4 |
|
5 |
use WPStaging\Framework\TemplateEngine\TemplateEngine;
|
6 |
|
7 |
+
/**
|
8 |
+
* Class HookedTemplate
|
9 |
+
*
|
10 |
+
* @todo Remove this since Hooks is no more.
|
11 |
+
*
|
12 |
+
* @package WPStaging\Framework\Adapter
|
13 |
+
*/
|
14 |
class HookedTemplate
|
15 |
{
|
16 |
|
|
|
|
|
|
|
17 |
/** @var TemplateEngine */
|
18 |
private $templateEngine;
|
19 |
|
20 |
+
public function __construct(TemplateEngine $templateEngine)
|
21 |
{
|
|
|
22 |
$this->templateEngine = $templateEngine;
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* @return TemplateEngine
|
27 |
*/
|
Framework/Adapter/Hooks.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WPStaging\Framework\Adapter;
|
4 |
-
|
5 |
-
use WPStaging\Framework\Adapter\Dto\HookDto;
|
6 |
-
|
7 |
-
final class Hooks
|
8 |
-
{
|
9 |
-
/** @var HookDto[]|array */
|
10 |
-
private $actions = [];
|
11 |
-
|
12 |
-
/** @var HookDto[]|array */
|
13 |
-
private $filters = [];
|
14 |
-
|
15 |
-
/** @noinspection PhpUnused */
|
16 |
-
public function addAction(HookDto $dto)
|
17 |
-
{
|
18 |
-
$this->actions[] = $dto;
|
19 |
-
}
|
20 |
-
|
21 |
-
/** @noinspection PhpUnused */
|
22 |
-
public function addFilter(HookDto $dto)
|
23 |
-
{
|
24 |
-
$this->filters[] = $dto;
|
25 |
-
}
|
26 |
-
|
27 |
-
public function init()
|
28 |
-
{
|
29 |
-
foreach ($this->filters as $filter) {
|
30 |
-
add_filter(
|
31 |
-
$filter->getHook(),
|
32 |
-
[$filter->getComponent(), $filter->getCallback()],
|
33 |
-
$filter->getPriority(),
|
34 |
-
$filter->getAcceptedArgs()
|
35 |
-
);
|
36 |
-
}
|
37 |
-
|
38 |
-
foreach ($this->actions as $action) {
|
39 |
-
add_action(
|
40 |
-
$action->getHook(),
|
41 |
-
[$action->getComponent(), $action->getCallback()],
|
42 |
-
$action->getPriority(),
|
43 |
-
$action->getAcceptedArgs()
|
44 |
-
);
|
45 |
-
}
|
46 |
-
}
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Framework/Component/AbstractComponent.php
CHANGED
@@ -4,74 +4,22 @@
|
|
4 |
|
5 |
namespace WPStaging\Framework\Component;
|
6 |
|
7 |
-
use WPStaging\Framework\Adapter\Dto\HookDto;
|
8 |
-
use WPStaging\Framework\Adapter\Hooks;
|
9 |
use WPStaging\Framework\Security\AccessToken;
|
10 |
|
11 |
abstract class AbstractComponent implements ComponentInterface
|
12 |
{
|
13 |
-
/** @var Hooks */
|
14 |
-
private $hooks;
|
15 |
|
16 |
/** @var AccessToken */
|
17 |
private $accessToken;
|
18 |
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
-
$this->hooks = $hooks;
|
22 |
-
|
23 |
// Todo: Inject using DI
|
24 |
$this->accessToken = new AccessToken;
|
25 |
|
26 |
$this->registerHooks();
|
27 |
}
|
28 |
|
29 |
-
/**
|
30 |
-
* @param string $action
|
31 |
-
* @param string $method
|
32 |
-
* @param int $acceptedArgs
|
33 |
-
* @param int $priority
|
34 |
-
* @noinspection PhpUnused
|
35 |
-
*/
|
36 |
-
public function addAction($action, $method, $acceptedArgs = 0, $priority = 10)
|
37 |
-
{
|
38 |
-
$dto = $this->generateDto($action, $method, $acceptedArgs, $priority);
|
39 |
-
$this->hooks->addAction($dto);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @param string $action
|
44 |
-
* @param string $method
|
45 |
-
* @param int $acceptedArgs
|
46 |
-
* @param int $priority
|
47 |
-
* @noinspection PhpUnused
|
48 |
-
*/
|
49 |
-
public function addFilter($action, $method, $acceptedArgs = 0, $priority = 10)
|
50 |
-
{
|
51 |
-
$dto = $this->generateDto($action, $method, $acceptedArgs, $priority);
|
52 |
-
$this->hooks->addFilter($dto);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @param string $action
|
57 |
-
* @param string $method
|
58 |
-
* @param int $acceptedArgs
|
59 |
-
* @param int $priority
|
60 |
-
*
|
61 |
-
* @return HookDto
|
62 |
-
*/
|
63 |
-
private function generateDto($action, $method, $acceptedArgs = 0, $priority = 10)
|
64 |
-
{
|
65 |
-
$dto = new HookDto;
|
66 |
-
$dto->setHook($action);
|
67 |
-
$dto->setComponent($this);
|
68 |
-
$dto->setCallback($method);
|
69 |
-
$dto->setAcceptedArgs($acceptedArgs);
|
70 |
-
$dto->setPriority($priority);
|
71 |
-
|
72 |
-
return $dto;
|
73 |
-
}
|
74 |
-
|
75 |
/**
|
76 |
* @return bool Whether the current request should render this template.
|
77 |
*/
|
4 |
|
5 |
namespace WPStaging\Framework\Component;
|
6 |
|
|
|
|
|
7 |
use WPStaging\Framework\Security\AccessToken;
|
8 |
|
9 |
abstract class AbstractComponent implements ComponentInterface
|
10 |
{
|
|
|
|
|
11 |
|
12 |
/** @var AccessToken */
|
13 |
private $accessToken;
|
14 |
|
15 |
+
public function __construct()
|
16 |
{
|
|
|
|
|
17 |
// Todo: Inject using DI
|
18 |
$this->accessToken = new AccessToken;
|
19 |
|
20 |
$this->registerHooks();
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
/**
|
24 |
* @return bool Whether the current request should render this template.
|
25 |
*/
|
Framework/Component/AbstractTemplateComponent.php
CHANGED
@@ -17,7 +17,7 @@ abstract class AbstractTemplateComponent extends AbstractComponent implements Re
|
|
17 |
|
18 |
public function __construct(HookedTemplate $hookedTemplate)
|
19 |
{
|
20 |
-
parent::__construct(
|
21 |
$this->templateEngine = $hookedTemplate->getTemplateEngine();
|
22 |
}
|
23 |
|
17 |
|
18 |
public function __construct(HookedTemplate $hookedTemplate)
|
19 |
{
|
20 |
+
parent::__construct();
|
21 |
$this->templateEngine = $hookedTemplate->getTemplateEngine();
|
22 |
}
|
23 |
|
Framework/Database/DatabaseRestore.php
CHANGED
@@ -306,7 +306,7 @@ class DatabaseRestore
|
|
306 |
|
307 |
private function isShouldStop()
|
308 |
{
|
309 |
-
return $this->shouldStop
|
310 |
}
|
311 |
|
312 |
private function exec($query)
|
306 |
|
307 |
private function isShouldStop()
|
308 |
{
|
309 |
+
return $this->shouldStop;
|
310 |
}
|
311 |
|
312 |
private function exec($query)
|
Framework/Filesystem/Filesystem.php
CHANGED
@@ -130,7 +130,7 @@ class Filesystem
|
|
130 |
continue;
|
131 |
}
|
132 |
|
133 |
-
if ($this->shouldStop
|
134 |
return false;
|
135 |
}
|
136 |
}
|
@@ -264,7 +264,7 @@ class Filesystem
|
|
264 |
|
265 |
foreach ($iterator as $file) {
|
266 |
$this->delete($file->getPathname(), $isUseNotPath);
|
267 |
-
if ($this->shouldStop
|
268 |
return false;
|
269 |
}
|
270 |
}
|
130 |
continue;
|
131 |
}
|
132 |
|
133 |
+
if ($this->shouldStop) {
|
134 |
return false;
|
135 |
}
|
136 |
}
|
264 |
|
265 |
foreach ($iterator as $file) {
|
266 |
$this->delete($file->getPathname(), $isUseNotPath);
|
267 |
+
if ($this->shouldStop) {
|
268 |
return false;
|
269 |
}
|
270 |
}
|
Frontend/Frontend.php
CHANGED
@@ -38,10 +38,8 @@ class Frontend extends InjectionAware
|
|
38 |
*/
|
39 |
private function defineHooks()
|
40 |
{
|
41 |
-
|
42 |
-
|
43 |
-
$loader->addAction("init", $this, "checkPermissions");
|
44 |
-
$loader->addFilter("wp_before_admin_bar_render", $this, "changeSiteName");
|
45 |
}
|
46 |
|
47 |
/**
|
@@ -212,4 +210,4 @@ class Frontend extends InjectionAware
|
|
212 |
update_option("wpstg_rmpermalinks_executed", "true");
|
213 |
}
|
214 |
|
215 |
-
}
|
38 |
*/
|
39 |
private function defineHooks()
|
40 |
{
|
41 |
+
add_action("init", [$this, "checkPermissions"]);
|
42 |
+
add_filter("wp_before_admin_bar_render", [$this, "changeSiteName"]);
|
|
|
|
|
43 |
}
|
44 |
|
45 |
/**
|
210 |
update_option("wpstg_rmpermalinks_executed", "true");
|
211 |
}
|
212 |
|
213 |
+
}
|
Requirements/WpstgFreeRequirements.php
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('WpstgFreeRequirements')) {
|
4 |
+
require_once 'WpstgRequirements.php';
|
5 |
+
|
6 |
+
class WpstgFreeRequirements extends WpstgRequirements
|
7 |
+
{
|
8 |
+
public function checkRequirements()
|
9 |
+
{
|
10 |
+
$this->proVersionMustNotBeEnabled();
|
11 |
+
$this->anotherInstanceOfWpstagingMustNotBeEnabled();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Prevent conflicts when WPSTAGING Pro is active.
|
16 |
+
*/
|
17 |
+
private function proVersionMustNotBeEnabled()
|
18 |
+
{
|
19 |
+
// Early bail: Pro is not loaded, therefore there's no need for further checks.
|
20 |
+
if (!defined('WPSTG_PRO_LOADED')) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
$proPlugin = plugin_basename(WPSTG_PRO_LOADED);
|
25 |
+
$freePlugin = plugin_basename($this->pluginFile);
|
26 |
+
|
27 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
28 |
+
|
29 |
+
if (!is_multisite()) {
|
30 |
+
/*
|
31 |
+
* Pro active
|
32 |
+
* Free active
|
33 |
+
*
|
34 |
+
* Result: Deactivate Free
|
35 |
+
*/
|
36 |
+
if (is_plugin_active($proPlugin)) {
|
37 |
+
if (current_user_can('deactivate_plugin', $freePlugin)) {
|
38 |
+
unset($_GET['activate']);
|
39 |
+
deactivate_plugins($freePlugin);
|
40 |
+
|
41 |
+
$this->notificationMessage = __('WP STAGING Pro is activated, therefore WP STAGING Basic was automatically disabled.', 'wp-staging');
|
42 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
43 |
+
|
44 |
+
throw new RuntimeException(sprintf("WP STAGING Pro is activated, therefore WP STAGING Basic was automatically disabled. Pro version that was active: %s, Basic version that was disabled: %s", $proPlugin, $freePlugin));
|
45 |
+
} else {
|
46 |
+
$this->notificationMessage = __('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Please ask the site administrator to leave only one instance of WP STAGING active.', 'wp-staging');
|
47 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
48 |
+
|
49 |
+
throw new RuntimeException(sprintf('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Plugin that was loaded: %s, Plugin that was prevented from loading: %s', $freePlugin, $proPlugin));
|
50 |
+
}
|
51 |
+
}
|
52 |
+
} else {
|
53 |
+
if (!is_network_admin()) {
|
54 |
+
/*
|
55 |
+
* Pro active site-level
|
56 |
+
* Free active site-level
|
57 |
+
* Free deactivated network-level
|
58 |
+
*
|
59 |
+
* Result: Deactivate Free site-level
|
60 |
+
*/
|
61 |
+
if (
|
62 |
+
is_plugin_active($proPlugin) &&
|
63 |
+
is_plugin_active($freePlugin) &&
|
64 |
+
!is_plugin_active_for_network($freePlugin)
|
65 |
+
) {
|
66 |
+
if (current_user_can('deactivate_plugin', $freePlugin)) {
|
67 |
+
unset($_GET['activate']);
|
68 |
+
deactivate_plugins($freePlugin);
|
69 |
+
|
70 |
+
$this->notificationMessage = __('WP STAGING Pro is activated, therefore WP STAGING Basic was automatically disabled.', 'wp-staging');
|
71 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
72 |
+
|
73 |
+
throw new RuntimeException(sprintf("WP STAGING Pro is activated, therefore WP STAGING Basic was automatically disabled. Pro version that was active: %s, Basic version that was disabled: %s", $proPlugin, $freePlugin));
|
74 |
+
} else {
|
75 |
+
$this->notificationMessage = __('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Please ask the site administrator to leave only one instance of WP STAGING active.', 'wp-staging');
|
76 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
77 |
+
|
78 |
+
throw new RuntimeException(sprintf('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Plugin that was loaded: %s, Plugin that was prevented from loading: %s', $freePlugin, $proPlugin));
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/*
|
83 |
+
* Pro active site-level
|
84 |
+
* Free active network-level
|
85 |
+
*
|
86 |
+
* Result: Deactivate Pro site-level
|
87 |
+
*/
|
88 |
+
if (
|
89 |
+
is_plugin_active($proPlugin) &&
|
90 |
+
is_plugin_active_for_network($freePlugin)
|
91 |
+
) {
|
92 |
+
if (current_user_can('deactivate_plugin', $proPlugin)) {
|
93 |
+
unset($_GET['activate']);
|
94 |
+
deactivate_plugins($proPlugin);
|
95 |
+
|
96 |
+
$this->notificationMessage = __('WP STAGING Basic is activated network-wide, therefore WP STAGING Pro was automatically disabled. Please disable WP STAGING Basic network-wide to enable WP STAGING Pro.', 'wp-staging');
|
97 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
98 |
+
|
99 |
+
throw new RuntimeException(sprintf("WP STAGING Basic is activated networkwide, therefore WP STAGING Pro was automatically disabled. Basic version that was activate networkwide: %s, Pro version that was disabled: %s", $freePlugin, $proPlugin));
|
100 |
+
} else {
|
101 |
+
$this->notificationMessage = __('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Please ask the site administrator to leave only one instance of WP STAGING active.', 'wp-staging');
|
102 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
103 |
+
|
104 |
+
throw new RuntimeException(sprintf('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Plugin that was loaded: %s, Plugin that was prevented from loading: %s', $freePlugin, $proPlugin));
|
105 |
+
}
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
/*
|
109 |
+
* Pro active network-level
|
110 |
+
* Free active network-level
|
111 |
+
*
|
112 |
+
* Result: Deactivate Free network-level
|
113 |
+
*/
|
114 |
+
if (is_plugin_active_for_network($proPlugin)) {
|
115 |
+
if (current_user_can('manage_network_plugins')) {
|
116 |
+
unset($_GET['activate']);
|
117 |
+
deactivate_plugins($freePlugin, null, true);
|
118 |
+
|
119 |
+
$this->notificationMessage = __('WP STAGING Pro is activated network-wide, therefore WP STAGING Basic was disabled network-wide.', 'wp-staging');
|
120 |
+
add_action('network_admin_notices', [$this, '_displayWarning']);
|
121 |
+
|
122 |
+
throw new RuntimeException(sprintf("WP STAGING Pro is activated networkwide, therefore WP STAGING Basic networkwide was automatically disabled. Pro version that was activate networkwide: %s, Basic version that was disabled networkwide: %s", $proPlugin, $freePlugin));
|
123 |
+
} else {
|
124 |
+
$this->notificationMessage = __('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Please ask the site administrator to leave only one instance of WP STAGING active.', 'wp-staging');
|
125 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
126 |
+
|
127 |
+
throw new RuntimeException(sprintf('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Plugin that was loaded: %s, Plugin that was prevented from loading: %s', $freePlugin, $proPlugin));
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Catch-all to prevent conflicts when another instance of WPSTAGING is active.
|
136 |
+
*/
|
137 |
+
private function anotherInstanceOfWpstagingMustNotBeEnabled()
|
138 |
+
{
|
139 |
+
$oldVersionsLoaded = defined('WPSTG_PLUGIN_DIR') || defined('WPSTG_PLUGIN_FILE');
|
140 |
+
$proVersionLoaded = defined('WPSTG_PRO_LOADED');
|
141 |
+
$anotherFreeVersionLoaded = defined('WPSTG_FREE_LOADED') && WPSTG_FREE_LOADED !== $this->pluginFile;
|
142 |
+
|
143 |
+
if ($oldVersionsLoaded || $proVersionLoaded || $anotherFreeVersionLoaded) {
|
144 |
+
$this->notificationMessage = __('Another instance of WP STAGING is activated, therefore other instances of WP STAGING were automatically prevented from running to avoid errors. Please leave only one instance of the WP STAGING plugin active.', 'wp-staging');
|
145 |
+
|
146 |
+
if (is_network_admin() && current_user_can('manage_network_plugins')) {
|
147 |
+
add_action('network_admin_notices', [$this, '_displayWarning']);
|
148 |
+
} elseif (!is_network_admin() && current_user_can('activate_plugins')) {
|
149 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
150 |
+
} elseif (!is_network_admin() && !current_user_can('activate_plugins')) {
|
151 |
+
$this->notificationMessage = __('Another instance of WP STAGING was activated, therefore other instances of the WP STAGING plugin were prevented from loading. Please ask the site administrator to leave only one instance of WP STAGING active.', 'wp-staging');
|
152 |
+
add_action('admin_notices', [$this, '_displayWarning']);
|
153 |
+
}
|
154 |
+
|
155 |
+
throw new RuntimeException(sprintf("Another instance of WP STAGING is activated, therefore other instances of WP STAGING were automatically prevented from running to avoid errors. Please leave only one instance of the WP STAGING plugin active. Plugin that was prevented from loading: %s", $this->pluginFile));
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
Requirements/WpstgRequirements.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('WpstgRequirements')) {
|
4 |
+
abstract class WpstgRequirements
|
5 |
+
{
|
6 |
+
protected $notificationTitle = '';
|
7 |
+
protected $notificationMessage = '';
|
8 |
+
protected $pluginFile;
|
9 |
+
|
10 |
+
public function __construct($pluginFile)
|
11 |
+
{
|
12 |
+
$this->pluginFile = $pluginFile;
|
13 |
+
}
|
14 |
+
|
15 |
+
abstract public function checkRequirements();
|
16 |
+
|
17 |
+
public function _displayWarning()
|
18 |
+
{
|
19 |
+
$title = esc_html($this->notificationTitle ?: __('WP STAGING', 'wp-staging'));
|
20 |
+
$message = wp_kses_post($this->notificationMessage);
|
21 |
+
|
22 |
+
echo <<<MESSAGE
|
23 |
+
<div class="notice-warning notice is-dismissible">
|
24 |
+
<p style="font-weight: bold;">$title</p>
|
25 |
+
<p>$message</p>
|
26 |
+
</div>
|
27 |
+
MESSAGE;
|
28 |
+
|
29 |
+
// Cleanup the state.
|
30 |
+
$this->notificationTitle = '';
|
31 |
+
$this->notificationMessage = '';
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
_init.php
CHANGED
@@ -36,7 +36,6 @@ if (file_exists(plugin_dir_path(__FILE__) . 'Pro/constants.php')) {
|
|
36 |
require_once plugin_dir_path(__FILE__) . 'constants.php';
|
37 |
}
|
38 |
|
39 |
-
|
40 |
/**
|
41 |
* Do not show update notifications for WP STAGING Pro on the staging site
|
42 |
* @param object
|
@@ -75,7 +74,6 @@ $pluginRequirements = new Wpstg_Requirements_Check(array(
|
|
75 |
'file' => __FILE__,
|
76 |
));
|
77 |
|
78 |
-
|
79 |
if ($pluginRequirements->passes()) {
|
80 |
|
81 |
// @todo remove legacy custom auto-loader in WPStaging\Utils\Autoloader and use this composer based one instead!
|
@@ -90,23 +88,12 @@ if ($pluginRequirements->passes()) {
|
|
90 |
*/
|
91 |
|
92 |
// Wordpress DB Object
|
93 |
-
|
94 |
-
$wpStaging->set("wpdb", $wpdb);
|
95 |
-
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
$wpStaging->set("wp_filter", function () use (&$wp_filter) {
|
100 |
-
return $wp_filter;
|
101 |
-
});
|
102 |
}
|
103 |
|
104 |
-
/**
|
105 |
-
* Inititalize WPStaging
|
106 |
-
*/
|
107 |
-
$wpStaging->run();
|
108 |
-
|
109 |
-
|
110 |
/**
|
111 |
* Installation Hooks
|
112 |
*/
|
36 |
require_once plugin_dir_path(__FILE__) . 'constants.php';
|
37 |
}
|
38 |
|
|
|
39 |
/**
|
40 |
* Do not show update notifications for WP STAGING Pro on the staging site
|
41 |
* @param object
|
74 |
'file' => __FILE__,
|
75 |
));
|
76 |
|
|
|
77 |
if ($pluginRequirements->passes()) {
|
78 |
|
79 |
// @todo remove legacy custom auto-loader in WPStaging\Utils\Autoloader and use this composer based one instead!
|
88 |
*/
|
89 |
|
90 |
// Wordpress DB Object
|
91 |
+
global $wpdb;
|
|
|
|
|
92 |
|
93 |
+
if ($wpdb instanceof \wpdb) {
|
94 |
+
$wpStaging->set("wpdb", $wpdb);
|
|
|
|
|
|
|
95 |
}
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
/**
|
98 |
* Installation Hooks
|
99 |
*/
|
constants.php
CHANGED
@@ -5,7 +5,7 @@ namespace WPStaging;
|
|
5 |
|
6 |
// WP STAGING version number
|
7 |
if (!defined('WPSTG_VERSION')) {
|
8 |
-
define('WPSTG_VERSION', '2.7.
|
9 |
}
|
10 |
|
11 |
// Compatible up to WordPress Version
|
5 |
|
6 |
// WP STAGING version number
|
7 |
if (!defined('WPSTG_VERSION')) {
|
8 |
+
define('WPSTG_VERSION', '2.7.7');
|
9 |
}
|
10 |
|
11 |
// Compatible up to WordPress Version
|
readme.txt
CHANGED
@@ -9,7 +9,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
9 |
Tags: backup, staging, duplication, clone, migration
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.5
|
12 |
-
Stable tag: 2.7.
|
13 |
Requires PHP: 5.5
|
14 |
|
15 |
A duplicator plugin - clone/move, duplicate & migrate websites to staging, backup and development sites that only authorized users can access.
|
@@ -157,6 +157,9 @@ https://wp-staging.com
|
|
157 |
|
158 |
== Changelog ==
|
159 |
|
|
|
|
|
|
|
160 |
= 2.7.6 =
|
161 |
* New: Compatible up to WordPress 5.5.1
|
162 |
* New: Add WP_ENVIRONMENT_TYPE constant for staging site
|
9 |
Tags: backup, staging, duplication, clone, migration
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.5
|
12 |
+
Stable tag: 2.7.7
|
13 |
Requires PHP: 5.5
|
14 |
|
15 |
A duplicator plugin - clone/move, duplicate & migrate websites to staging, backup and development sites that only authorized users can access.
|
157 |
|
158 |
== Changelog ==
|
159 |
|
160 |
+
= 2.7.7 =
|
161 |
+
* Fix: Fatal error on activation if PHP version < 7.x version on some circumstances
|
162 |
+
|
163 |
= 2.7.6 =
|
164 |
* New: Compatible up to WordPress 5.5.1
|
165 |
* New: Add WP_ENVIRONMENT_TYPE constant for staging site
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -61,7 +61,6 @@ return array(
|
|
61 |
'Symfony\\Component\\Finder\\Shell\\Shell' => $vendorDir . '/symfony/finder/Shell/Shell.php',
|
62 |
'Symfony\\Component\\Finder\\SplFileInfo' => $vendorDir . '/symfony/finder/SplFileInfo.php',
|
63 |
'Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php',
|
64 |
-
'WPStaging\\Backend\\Activation\\Activation' => $baseDir . '/Backend/Activation/Activation.php',
|
65 |
'WPStaging\\Backend\\Activation\\Welcome' => $baseDir . '/Backend/Activation/Welcome.php',
|
66 |
'WPStaging\\Backend\\Administrator' => $baseDir . '/Backend/Administrator.php',
|
67 |
'WPStaging\\Backend\\Feedback\\Feedback' => $baseDir . '/Backend/Feedback/Feedback.php',
|
@@ -167,10 +166,8 @@ return array(
|
|
167 |
'WPStaging\\Framework\\Adapter\\Database\\WpDbAdapter' => $baseDir . '/Framework/Adapter/Database/WpDbAdapter.php',
|
168 |
'WPStaging\\Framework\\Adapter\\DateTimeAdapter' => $baseDir . '/Framework/Adapter/DateTimeAdapter.php',
|
169 |
'WPStaging\\Framework\\Adapter\\Directory' => $baseDir . '/Framework/Adapter/Directory.php',
|
170 |
-
'WPStaging\\Framework\\Adapter\\Dto\\HookDto' => $baseDir . '/Framework/Adapter/Dto/HookDto.php',
|
171 |
'WPStaging\\Framework\\Adapter\\Dto\\JedDto' => $baseDir . '/Framework/Adapter/Dto/JedDto.php',
|
172 |
'WPStaging\\Framework\\Adapter\\HookedTemplate' => $baseDir . '/Framework/Adapter/HookedTemplate.php',
|
173 |
-
'WPStaging\\Framework\\Adapter\\Hooks' => $baseDir . '/Framework/Adapter/Hooks.php',
|
174 |
'WPStaging\\Framework\\Adapter\\Maintenance' => $baseDir . '/Framework/Adapter/Maintenance.php',
|
175 |
'WPStaging\\Framework\\Adapter\\SourceDatabase' => $baseDir . '/Framework/Adapter/SourceDatabase.php',
|
176 |
'WPStaging\\Framework\\Adapter\\Translation' => $baseDir . '/Framework/Adapter/Translation.php',
|
@@ -276,7 +273,6 @@ return array(
|
|
276 |
'WPStaging\\Utils\\Htaccess' => $baseDir . '/Core/Utils/Htaccess.php',
|
277 |
'WPStaging\\Utils\\IISWebConfig' => $baseDir . '/Core/Utils/IISWebConfig.php',
|
278 |
'WPStaging\\Utils\\Info' => $baseDir . '/Core/Utils/Info.php',
|
279 |
-
'WPStaging\\Utils\\Loader' => $baseDir . '/Core/Utils/Loader.php',
|
280 |
'WPStaging\\Utils\\Logger' => $baseDir . '/Core/Utils/Logger.php',
|
281 |
'WPStaging\\Utils\\Multisite' => $baseDir . '/Core/Utils/Multisite.php',
|
282 |
'WPStaging\\Utils\\MySQL' => $baseDir . '/Core/Utils/MySQL.php',
|
61 |
'Symfony\\Component\\Finder\\Shell\\Shell' => $vendorDir . '/symfony/finder/Shell/Shell.php',
|
62 |
'Symfony\\Component\\Finder\\SplFileInfo' => $vendorDir . '/symfony/finder/SplFileInfo.php',
|
63 |
'Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php',
|
|
|
64 |
'WPStaging\\Backend\\Activation\\Welcome' => $baseDir . '/Backend/Activation/Welcome.php',
|
65 |
'WPStaging\\Backend\\Administrator' => $baseDir . '/Backend/Administrator.php',
|
66 |
'WPStaging\\Backend\\Feedback\\Feedback' => $baseDir . '/Backend/Feedback/Feedback.php',
|
166 |
'WPStaging\\Framework\\Adapter\\Database\\WpDbAdapter' => $baseDir . '/Framework/Adapter/Database/WpDbAdapter.php',
|
167 |
'WPStaging\\Framework\\Adapter\\DateTimeAdapter' => $baseDir . '/Framework/Adapter/DateTimeAdapter.php',
|
168 |
'WPStaging\\Framework\\Adapter\\Directory' => $baseDir . '/Framework/Adapter/Directory.php',
|
|
|
169 |
'WPStaging\\Framework\\Adapter\\Dto\\JedDto' => $baseDir . '/Framework/Adapter/Dto/JedDto.php',
|
170 |
'WPStaging\\Framework\\Adapter\\HookedTemplate' => $baseDir . '/Framework/Adapter/HookedTemplate.php',
|
|
|
171 |
'WPStaging\\Framework\\Adapter\\Maintenance' => $baseDir . '/Framework/Adapter/Maintenance.php',
|
172 |
'WPStaging\\Framework\\Adapter\\SourceDatabase' => $baseDir . '/Framework/Adapter/SourceDatabase.php',
|
173 |
'WPStaging\\Framework\\Adapter\\Translation' => $baseDir . '/Framework/Adapter/Translation.php',
|
273 |
'WPStaging\\Utils\\Htaccess' => $baseDir . '/Core/Utils/Htaccess.php',
|
274 |
'WPStaging\\Utils\\IISWebConfig' => $baseDir . '/Core/Utils/IISWebConfig.php',
|
275 |
'WPStaging\\Utils\\Info' => $baseDir . '/Core/Utils/Info.php',
|
|
|
276 |
'WPStaging\\Utils\\Logger' => $baseDir . '/Core/Utils/Logger.php',
|
277 |
'WPStaging\\Utils\\Multisite' => $baseDir . '/Core/Utils/Multisite.php',
|
278 |
'WPStaging\\Utils\\MySQL' => $baseDir . '/Core/Utils/MySQL.php',
|
vendor/composer/autoload_static.php
CHANGED
@@ -106,7 +106,6 @@ class ComposerStaticInitwpstgfree
|
|
106 |
'Symfony\\Component\\Finder\\Shell\\Shell' => __DIR__ . '/..' . '/symfony/finder/Shell/Shell.php',
|
107 |
'Symfony\\Component\\Finder\\SplFileInfo' => __DIR__ . '/..' . '/symfony/finder/SplFileInfo.php',
|
108 |
'Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php',
|
109 |
-
'WPStaging\\Backend\\Activation\\Activation' => __DIR__ . '/../..' . '/Backend/Activation/Activation.php',
|
110 |
'WPStaging\\Backend\\Activation\\Welcome' => __DIR__ . '/../..' . '/Backend/Activation/Welcome.php',
|
111 |
'WPStaging\\Backend\\Administrator' => __DIR__ . '/../..' . '/Backend/Administrator.php',
|
112 |
'WPStaging\\Backend\\Feedback\\Feedback' => __DIR__ . '/../..' . '/Backend/Feedback/Feedback.php',
|
@@ -212,10 +211,8 @@ class ComposerStaticInitwpstgfree
|
|
212 |
'WPStaging\\Framework\\Adapter\\Database\\WpDbAdapter' => __DIR__ . '/../..' . '/Framework/Adapter/Database/WpDbAdapter.php',
|
213 |
'WPStaging\\Framework\\Adapter\\DateTimeAdapter' => __DIR__ . '/../..' . '/Framework/Adapter/DateTimeAdapter.php',
|
214 |
'WPStaging\\Framework\\Adapter\\Directory' => __DIR__ . '/../..' . '/Framework/Adapter/Directory.php',
|
215 |
-
'WPStaging\\Framework\\Adapter\\Dto\\HookDto' => __DIR__ . '/../..' . '/Framework/Adapter/Dto/HookDto.php',
|
216 |
'WPStaging\\Framework\\Adapter\\Dto\\JedDto' => __DIR__ . '/../..' . '/Framework/Adapter/Dto/JedDto.php',
|
217 |
'WPStaging\\Framework\\Adapter\\HookedTemplate' => __DIR__ . '/../..' . '/Framework/Adapter/HookedTemplate.php',
|
218 |
-
'WPStaging\\Framework\\Adapter\\Hooks' => __DIR__ . '/../..' . '/Framework/Adapter/Hooks.php',
|
219 |
'WPStaging\\Framework\\Adapter\\Maintenance' => __DIR__ . '/../..' . '/Framework/Adapter/Maintenance.php',
|
220 |
'WPStaging\\Framework\\Adapter\\SourceDatabase' => __DIR__ . '/../..' . '/Framework/Adapter/SourceDatabase.php',
|
221 |
'WPStaging\\Framework\\Adapter\\Translation' => __DIR__ . '/../..' . '/Framework/Adapter/Translation.php',
|
@@ -321,7 +318,6 @@ class ComposerStaticInitwpstgfree
|
|
321 |
'WPStaging\\Utils\\Htaccess' => __DIR__ . '/../..' . '/Core/Utils/Htaccess.php',
|
322 |
'WPStaging\\Utils\\IISWebConfig' => __DIR__ . '/../..' . '/Core/Utils/IISWebConfig.php',
|
323 |
'WPStaging\\Utils\\Info' => __DIR__ . '/../..' . '/Core/Utils/Info.php',
|
324 |
-
'WPStaging\\Utils\\Loader' => __DIR__ . '/../..' . '/Core/Utils/Loader.php',
|
325 |
'WPStaging\\Utils\\Logger' => __DIR__ . '/../..' . '/Core/Utils/Logger.php',
|
326 |
'WPStaging\\Utils\\Multisite' => __DIR__ . '/../..' . '/Core/Utils/Multisite.php',
|
327 |
'WPStaging\\Utils\\MySQL' => __DIR__ . '/../..' . '/Core/Utils/MySQL.php',
|
106 |
'Symfony\\Component\\Finder\\Shell\\Shell' => __DIR__ . '/..' . '/symfony/finder/Shell/Shell.php',
|
107 |
'Symfony\\Component\\Finder\\SplFileInfo' => __DIR__ . '/..' . '/symfony/finder/SplFileInfo.php',
|
108 |
'Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php',
|
|
|
109 |
'WPStaging\\Backend\\Activation\\Welcome' => __DIR__ . '/../..' . '/Backend/Activation/Welcome.php',
|
110 |
'WPStaging\\Backend\\Administrator' => __DIR__ . '/../..' . '/Backend/Administrator.php',
|
111 |
'WPStaging\\Backend\\Feedback\\Feedback' => __DIR__ . '/../..' . '/Backend/Feedback/Feedback.php',
|
211 |
'WPStaging\\Framework\\Adapter\\Database\\WpDbAdapter' => __DIR__ . '/../..' . '/Framework/Adapter/Database/WpDbAdapter.php',
|
212 |
'WPStaging\\Framework\\Adapter\\DateTimeAdapter' => __DIR__ . '/../..' . '/Framework/Adapter/DateTimeAdapter.php',
|
213 |
'WPStaging\\Framework\\Adapter\\Directory' => __DIR__ . '/../..' . '/Framework/Adapter/Directory.php',
|
|
|
214 |
'WPStaging\\Framework\\Adapter\\Dto\\JedDto' => __DIR__ . '/../..' . '/Framework/Adapter/Dto/JedDto.php',
|
215 |
'WPStaging\\Framework\\Adapter\\HookedTemplate' => __DIR__ . '/../..' . '/Framework/Adapter/HookedTemplate.php',
|
|
|
216 |
'WPStaging\\Framework\\Adapter\\Maintenance' => __DIR__ . '/../..' . '/Framework/Adapter/Maintenance.php',
|
217 |
'WPStaging\\Framework\\Adapter\\SourceDatabase' => __DIR__ . '/../..' . '/Framework/Adapter/SourceDatabase.php',
|
218 |
'WPStaging\\Framework\\Adapter\\Translation' => __DIR__ . '/../..' . '/Framework/Adapter/Translation.php',
|
318 |
'WPStaging\\Utils\\Htaccess' => __DIR__ . '/../..' . '/Core/Utils/Htaccess.php',
|
319 |
'WPStaging\\Utils\\IISWebConfig' => __DIR__ . '/../..' . '/Core/Utils/IISWebConfig.php',
|
320 |
'WPStaging\\Utils\\Info' => __DIR__ . '/../..' . '/Core/Utils/Info.php',
|
|
|
321 |
'WPStaging\\Utils\\Logger' => __DIR__ . '/../..' . '/Core/Utils/Logger.php',
|
322 |
'WPStaging\\Utils\\Multisite' => __DIR__ . '/../..' . '/Core/Utils/Multisite.php',
|
323 |
'WPStaging\\Utils\\MySQL' => __DIR__ . '/../..' . '/Core/Utils/MySQL.php',
|
wp-staging.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author: WP-STAGING
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi
|
10 |
-
* Version: 2.7.
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|
@@ -33,14 +33,60 @@ if (!defined("WPINC")) {
|
|
33 |
die;
|
34 |
}
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
define('WPSTG_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
39 |
}
|
40 |
|
41 |
-
//
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
-
|
|
|
|
|
|
7 |
* Author: WP-STAGING
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi
|
10 |
+
* Version: 2.7.7
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|
33 |
die;
|
34 |
}
|
35 |
|
36 |
+
if (!defined('WPSTG_FREE_LOADED')) {
|
37 |
+
define('WPSTG_FREE_LOADED', __FILE__);
|
|
|
38 |
}
|
39 |
|
40 |
+
// Standalone requirement-checking script
|
41 |
+
require_once 'Requirements/WpstgFreeRequirements.php';
|
42 |
+
|
43 |
+
if (!class_exists('WpstgFreeBootstrap')) {
|
44 |
+
class WpstgFreeBootstrap
|
45 |
+
{
|
46 |
+
private $shouldBootstrap = true;
|
47 |
+
private $requirements;
|
48 |
+
|
49 |
+
public function __construct(WpstgRequirements $requirements)
|
50 |
+
{
|
51 |
+
$this->requirements = $requirements;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function checkRequirements()
|
55 |
+
{
|
56 |
+
try {
|
57 |
+
$this->requirements->checkRequirements();
|
58 |
+
} catch (Exception $e) {
|
59 |
+
$this->shouldBootstrap = false;
|
60 |
+
|
61 |
+
if (defined('WP_DEBUG') && WP_DEBUG) {
|
62 |
+
error_log(sprintf("[Activation] WP STAGING: %s", $e->getMessage()));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
public function bootstrap()
|
68 |
+
{
|
69 |
+
// Early bail: Requirements not met.
|
70 |
+
if (!$this->shouldBootstrap) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
// Absolute path to plugin dir /var/www/.../plugins/wp-staging(-pro)
|
75 |
+
if (!defined('WPSTG_PLUGIN_DIR')) {
|
76 |
+
define('WPSTG_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
77 |
+
}
|
78 |
+
|
79 |
+
// Absolute path and name to main plugin entry file /var/www/.../plugins/wp-staging(-pro)/wp-staging(-pro).php
|
80 |
+
if (!defined('WPSTG_PLUGIN_FILE')) {
|
81 |
+
define('WPSTG_PLUGIN_FILE', __FILE__);
|
82 |
+
}
|
83 |
+
|
84 |
+
require_once(__DIR__ . '/_init.php');
|
85 |
+
}
|
86 |
+
}
|
87 |
}
|
88 |
|
89 |
+
$bootstrap = new WpstgFreeBootstrap(new WpstgFreeRequirements(__FILE__));
|
90 |
+
|
91 |
+
add_action('plugins_loaded', [$bootstrap, 'checkRequirements'], 5);
|
92 |
+
add_action('plugins_loaded', [$bootstrap, 'bootstrap'], 10);
|