Version Description
- Fix: If server is windows it will result in missing files after cloning and can lead to fatal errors of the staging site
Download this release
Release Info
Developer | ReneHermi |
Plugin | WP Staging – DB & File Duplicator & Migration |
Version | 2.6.8 |
Comparing to | |
See all releases |
Code changes from version 2.6.7 to 2.6.8
- Backend/Optimizer/wp-staging-optimizer.php +155 -116
- Core/Iterators/RecursiveFilterExclude.php +2 -2
- readme.txt +4 -1
- wp-staging.php +4 -4
Backend/Optimizer/wp-staging-optimizer.php
CHANGED
@@ -9,18 +9,18 @@
|
|
9 |
* Do not use any of these methods in wp staging code base as this plugin can be missing!
|
10 |
*
|
11 |
* Author: René Hermenau
|
12 |
-
* Version: 1.
|
13 |
* Author URI: https://wp-staging.com
|
14 |
* Credit: Original version made by Delicious Brains (WP Migrate DB). Thank you guys!
|
15 |
*/
|
16 |
|
17 |
-
|
18 |
-
if(
|
19 |
-
define(
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
* Get plugins dir
|
24 |
* @return string
|
25 |
* @todo Logic error here. If WP_CONTENT_DIR or WP_PLUGIN_DIR do not exists no value is returned.
|
26 |
* Does not throw error because WP_PLUGIN_DIR is defined with default value in WP core.
|
@@ -29,144 +29,182 @@ function wpstg_get_plugins_dir()
|
|
29 |
{
|
30 |
|
31 |
if (defined('WP_PLUGIN_DIR')) {
|
32 |
-
|
33 |
} else if (defined('WP_CONTENT_DIR')) {
|
34 |
-
|
35 |
}
|
36 |
return $pluginsDir;
|
37 |
}
|
|
|
38 |
/*
|
39 |
* Check if optimizer is enabled
|
40 |
* @return bool false if it's disabled
|
41 |
*
|
42 |
*/
|
43 |
|
44 |
-
function wpstg_is_enabled_optimizer()
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
*
|
58 |
* @param array $plugins numerically keyed array of plugin names
|
59 |
*
|
60 |
* @return array
|
61 |
*/
|
62 |
-
function wpstg_exclude_plugins(
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
|
81 |
-
add_filter(
|
82 |
|
83 |
/**
|
|
|
84 |
*
|
85 |
-
*
|
86 |
-
*
|
87 |
-
*
|
88 |
-
* @param $dir
|
89 |
*
|
90 |
-
* @return
|
91 |
*/
|
92 |
-
function
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
$wpstgRoot = wpstg_get_plugins_dir() . 'wp-staging';
|
98 |
|
99 |
-
|
100 |
-
|
|
|
101 |
|
|
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
return '';
|
109 |
-
}
|
110 |
-
return $themeDir;
|
111 |
-
}
|
112 |
|
113 |
-
|
114 |
}
|
115 |
|
116 |
-
add_filter(
|
117 |
-
add_filter( 'template_directory', 'wpstg_disable_theme' );
|
118 |
|
119 |
/**
|
120 |
-
* remove all plugins except wp-staging and wp-staging-pro from network-active plugins
|
121 |
*
|
122 |
-
*
|
123 |
*
|
124 |
-
*
|
|
|
|
|
|
|
125 |
*/
|
126 |
-
function
|
127 |
-
|
128 |
-
|
129 |
-
}
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
|
|
|
|
|
135 |
|
136 |
-
foreach ( array_keys( $plugins ) as $plugin ) {
|
137 |
-
if( false !== strpos( $plugin, 'wp-staging' ) || !isset( $blacklist_plugins[$plugin] ) ) {
|
138 |
-
continue;
|
139 |
-
}
|
140 |
-
unset( $plugins[$plugin] );
|
141 |
-
}
|
142 |
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
-
add_filter(
|
|
|
147 |
|
148 |
/**
|
149 |
* Should the current request be processed by Compatibility Mode?
|
150 |
*
|
151 |
* @return bool
|
152 |
*/
|
153 |
-
function wpstg_is_compatibility_mode_request()
|
|
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
|
166 |
-
|
167 |
-
|
168 |
|
169 |
-
|
170 |
}
|
171 |
|
172 |
/**
|
@@ -174,32 +212,33 @@ function wpstg_is_compatibility_mode_request() {
|
|
174 |
*
|
175 |
* This is to stop excluded plugins being deactivated after a migration, when a theme uses TGMPA to require a plugin to be always active.
|
176 |
*/
|
177 |
-
function wpstg_tgmpa_compatibility()
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
199 |
}
|
200 |
-
|
201 |
-
|
202 |
-
}
|
203 |
}
|
204 |
|
205 |
-
add_action(
|
9 |
* Do not use any of these methods in wp staging code base as this plugin can be missing!
|
10 |
*
|
11 |
* Author: René Hermenau
|
12 |
+
* Version: 1.2
|
13 |
* Author URI: https://wp-staging.com
|
14 |
* Credit: Original version made by Delicious Brains (WP Migrate DB). Thank you guys!
|
15 |
*/
|
16 |
|
17 |
+
// Version number of this mu-plugin. Important for automatic updates
|
18 |
+
if (!defined('WPSTG_OPTIMIZER_VERSION')) {
|
19 |
+
define('WPSTG_OPTIMIZER_VERSION', 1.2);
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* Get plugins dir
|
24 |
* @return string
|
25 |
* @todo Logic error here. If WP_CONTENT_DIR or WP_PLUGIN_DIR do not exists no value is returned.
|
26 |
* Does not throw error because WP_PLUGIN_DIR is defined with default value in WP core.
|
29 |
{
|
30 |
|
31 |
if (defined('WP_PLUGIN_DIR')) {
|
32 |
+
$pluginsDir = trailingslashit(WP_PLUGIN_DIR);
|
33 |
} else if (defined('WP_CONTENT_DIR')) {
|
34 |
+
$pluginsDir = trailingslashit(WP_CONTENT_DIR) . 'plugins/';
|
35 |
}
|
36 |
return $pluginsDir;
|
37 |
}
|
38 |
+
|
39 |
/*
|
40 |
* Check if optimizer is enabled
|
41 |
* @return bool false if it's disabled
|
42 |
*
|
43 |
*/
|
44 |
|
45 |
+
function wpstg_is_enabled_optimizer()
|
46 |
+
{
|
47 |
+
|
48 |
+
// Activate the Optimizer all the times.
|
49 |
+
// Until now we never had any issue with the Optimizer so keep the optimizer activated to make sure user does not disable it accidentally
|
50 |
+
// @todo remove this function in wp staging settings
|
51 |
+
return true;
|
52 |
|
53 |
+
$status = ( object )get_option('wpstg_settings');
|
54 |
+
|
55 |
+
if ($status && isset($status->optimizer) && $status->optimizer == 1) {
|
56 |
+
return true;
|
57 |
+
}
|
58 |
+
|
59 |
+
return false;
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* Check if certain plugins are excluded and still runing during wp staging requests
|
64 |
+
* @return boolean
|
65 |
+
*/
|
66 |
+
function pluginIsExcluded($plugin)
|
67 |
+
{
|
68 |
+
$excludedPlugins = get_option('wpstg_optimizer_excluded', array());
|
69 |
+
|
70 |
+
if (empty($excludedPlugins)) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
// Check for custom excluded plugins
|
75 |
+
foreach ($excludedPlugins as $excludedPlugin) {
|
76 |
+
if (false !== strpos($plugin, $excludedPlugin)) {
|
77 |
+
return true;
|
78 |
+
} else {
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Remove all plugins except wp-staging and wp-staging-pro from blog-active plugins
|
88 |
*
|
89 |
* @param array $plugins numerically keyed array of plugin names
|
90 |
*
|
91 |
* @return array
|
92 |
*/
|
93 |
+
function wpstg_exclude_plugins($plugins)
|
94 |
+
{
|
95 |
+
if (!is_array($plugins) || empty($plugins)) {
|
96 |
+
return $plugins;
|
97 |
+
}
|
98 |
+
|
99 |
+
if (!wpstg_is_compatibility_mode_request()) {
|
100 |
+
return $plugins;
|
101 |
+
}
|
102 |
+
|
103 |
+
foreach ($plugins as $key => $plugin) {
|
104 |
+
|
105 |
+
// Default filter. Must be at the beginning or wp staging plugin will be filtered and killed
|
106 |
+
if (false !== strpos($plugin, 'wp-staging') || pluginIsExcluded($plugin)) {
|
107 |
+
continue;
|
108 |
+
}
|
109 |
+
unset($plugins[$key]);
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
return $plugins;
|
114 |
}
|
115 |
|
116 |
+
add_filter('option_active_plugins', 'wpstg_exclude_plugins');
|
117 |
|
118 |
/**
|
119 |
+
* Remove all plugins except wp-staging and wp-staging-pro from network-active plugins
|
120 |
*
|
121 |
+
* @param array $plugins array of plugins keyed by name (name=>timestamp pairs)
|
|
|
|
|
|
|
122 |
*
|
123 |
+
* @return array
|
124 |
*/
|
125 |
+
function wpstg_exclude_site_plugins($plugins)
|
126 |
+
{
|
127 |
+
if (!is_array($plugins) || empty($plugins)) {
|
128 |
+
return $plugins;
|
129 |
+
}
|
|
|
130 |
|
131 |
+
if (!wpstg_is_compatibility_mode_request()) {
|
132 |
+
return $plugins;
|
133 |
+
}
|
134 |
|
135 |
+
foreach ($plugins as $key => $plugin) {
|
136 |
|
137 |
+
// Default filter. Must be at the beginning or wp staging plugin will be filtered and killed
|
138 |
+
if (false !== strpos($plugin, 'wp-staging') || pluginIsExcluded($plugin)) {
|
139 |
+
continue;
|
140 |
+
}
|
141 |
+
}
|
|
|
|
|
|
|
|
|
142 |
|
143 |
+
return $plugins;
|
144 |
}
|
145 |
|
146 |
+
add_filter('site_option_active_sitewide_plugins', 'wpstg_exclude_site_plugins');
|
|
|
147 |
|
148 |
/**
|
|
|
149 |
*
|
150 |
+
* Disables the theme during WP Staging AJAX requests
|
151 |
*
|
152 |
+
*
|
153 |
+
* @param $dir
|
154 |
+
*
|
155 |
+
* @return string
|
156 |
*/
|
157 |
+
function wpstg_disable_theme($dir)
|
158 |
+
{
|
159 |
+
$enableTheme = apply_filters('wpstg_optimizer_enable_theme', false);
|
|
|
160 |
|
161 |
+
if (wpstg_is_compatibility_mode_request() && false === $enableTheme) {
|
162 |
+
$wpstgRootPro = wpstg_get_plugins_dir() . 'wp-staging-pro';
|
163 |
+
$wpstgRoot = wpstg_get_plugins_dir() . 'wp-staging';
|
164 |
|
165 |
+
$file = DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Optimizer' . DIRECTORY_SEPARATOR . 'blank-theme' . DIRECTORY_SEPARATOR . 'functions.php';
|
166 |
+
$theme = DIRECTORY_SEPARATOR . 'Backend' . DIRECTORY_SEPARATOR . 'Optimizer' . DIRECTORY_SEPARATOR . 'blank-theme';
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
+
if (file_exists($wpstgRoot . $file)) {
|
170 |
+
return $wpstgRoot . $theme;
|
171 |
+
} elseif (file_exists($wpstgRootPro . $file)) {
|
172 |
+
return $wpstgRootPro . $theme;
|
173 |
+
} else {
|
174 |
+
return '';
|
175 |
+
}
|
176 |
+
return $themeDir;
|
177 |
+
}
|
178 |
+
|
179 |
+
return $dir;
|
180 |
}
|
181 |
|
182 |
+
add_filter('stylesheet_directory', 'wpstg_disable_theme');
|
183 |
+
add_filter('template_directory', 'wpstg_disable_theme');
|
184 |
|
185 |
/**
|
186 |
* Should the current request be processed by Compatibility Mode?
|
187 |
*
|
188 |
* @return bool
|
189 |
*/
|
190 |
+
function wpstg_is_compatibility_mode_request()
|
191 |
+
{
|
192 |
|
193 |
+
// Optimizer not enabled
|
194 |
+
if (!wpstg_is_enabled_optimizer()) {
|
195 |
+
return false;
|
196 |
+
}
|
197 |
|
198 |
+
if (!defined('DOING_AJAX') ||
|
199 |
+
!DOING_AJAX ||
|
200 |
+
!isset($_POST['action']) ||
|
201 |
+
false === strpos($_POST['action'], 'wpstg')
|
202 |
+
) {
|
203 |
|
204 |
+
return false;
|
205 |
+
}
|
206 |
|
207 |
+
return true;
|
208 |
}
|
209 |
|
210 |
/**
|
212 |
*
|
213 |
* This is to stop excluded plugins being deactivated after a migration, when a theme uses TGMPA to require a plugin to be always active.
|
214 |
*/
|
215 |
+
function wpstg_tgmpa_compatibility()
|
216 |
+
{
|
217 |
+
$remove_function = false;
|
218 |
+
|
219 |
+
// run on wpstg page
|
220 |
+
if (isset($_GET['page']) && 'wpstg_clone' == $_GET['page']) {
|
221 |
+
$remove_function = true;
|
222 |
+
}
|
223 |
+
// run on wpstg ajax requests
|
224 |
+
if (defined('DOING_AJAX') && DOING_AJAX && isset($_POST['action']) && false !== strpos($_POST['action'], 'wpstg')) {
|
225 |
+
$remove_function = true;
|
226 |
+
}
|
227 |
+
|
228 |
+
if ($remove_function) {
|
229 |
+
global $wp_filter;
|
230 |
+
$admin_init_functions = $wp_filter['admin_init'];
|
231 |
+
foreach ($admin_init_functions as $priority => $functions) {
|
232 |
+
foreach ($functions as $key => $function) {
|
233 |
+
// searching for function this way as can't rely on the calling class being named TGM_Plugin_Activation
|
234 |
+
if (false !== strpos($key, 'force_activation')) {
|
235 |
+
unset($wp_filter['admin_init'][$priority][$key]);
|
236 |
+
|
237 |
+
return;
|
238 |
+
}
|
239 |
}
|
240 |
+
}
|
241 |
+
}
|
|
|
242 |
}
|
243 |
|
244 |
+
add_action('admin_init', 'wpstg_tgmpa_compatibility', 1);
|
Core/Iterators/RecursiveFilterExclude.php
CHANGED
@@ -20,11 +20,11 @@ class RecursiveFilterExclude extends RecursiveFilterIterator
|
|
20 |
$subPath = $this->getInnerIterator()->getSubPathname();
|
21 |
|
22 |
// new line character on linux
|
23 |
-
if (false !== strpos($subPath,
|
24 |
return false;
|
25 |
}
|
26 |
// new line character on Windows
|
27 |
-
if (false !== strpos($subPath,
|
28 |
return false;
|
29 |
}
|
30 |
|
20 |
$subPath = $this->getInnerIterator()->getSubPathname();
|
21 |
|
22 |
// new line character on linux
|
23 |
+
if (false !== strpos($subPath, "\n")) {
|
24 |
return false;
|
25 |
}
|
26 |
// new line character on Windows
|
27 |
+
if (false !== strpos($subPath, "\r")) {
|
28 |
return false;
|
29 |
}
|
30 |
|
readme.txt
CHANGED
@@ -9,7 +9,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
9 |
Tags: staging, duplication, cloning, clone, migration, sandbox, test site, testing, backup, post, admin, administration, duplicate posts
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.3
|
12 |
-
Stable tag: 2.6.
|
13 |
Requires PHP: 5.3
|
14 |
|
15 |
A duplicator plugin - clone/move, duplicate & migrate live websites to independent staging and development sites that are accessible by authorized users only.
|
@@ -153,6 +153,9 @@ https://wp-staging.com
|
|
153 |
|
154 |
== Changelog ==
|
155 |
|
|
|
|
|
|
|
156 |
= 2.6.7 =
|
157 |
* Fix: Update function adds duplicate string to internal urls like https://example.com/staging/staging/wp-content/*
|
158 |
* New: Support for WP 5.3.2
|
9 |
Tags: staging, duplication, cloning, clone, migration, sandbox, test site, testing, backup, post, admin, administration, duplicate posts
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.3
|
12 |
+
Stable tag: 2.6.8
|
13 |
Requires PHP: 5.3
|
14 |
|
15 |
A duplicator plugin - clone/move, duplicate & migrate live websites to independent staging and development sites that are accessible by authorized users only.
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 2.6.8 =
|
157 |
+
* Fix: If server is windows it will result in missing files after cloning and can lead to fatal errors of the staging site
|
158 |
+
|
159 |
= 2.6.7 =
|
160 |
* Fix: Update function adds duplicate string to internal urls like https://example.com/staging/staging/wp-content/*
|
161 |
* New: Support for WP 5.3.2
|
wp-staging.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author: WP-Staging
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi, ilgityildirim
|
10 |
-
* Version: 2.6.
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|
@@ -39,7 +39,7 @@ if (!defined('WPSTG_PLUGIN_SLUG')) {
|
|
39 |
|
40 |
// Plugin Version
|
41 |
if (!defined('WPSTG_VERSION')) {
|
42 |
-
define('WPSTG_VERSION', '2.6.
|
43 |
}
|
44 |
|
45 |
// Compatible up to WordPress Version
|
@@ -52,9 +52,9 @@ if (!defined('WPSTG_PLUGIN_DIR')) {
|
|
52 |
define('WPSTG_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
53 |
}
|
54 |
|
55 |
-
//
|
56 |
if (!defined('WPSTG_OPTIMIZER_MUVERSION')) {
|
57 |
-
define('WPSTG_OPTIMIZER_MUVERSION', 1.
|
58 |
}
|
59 |
|
60 |
// URL of the base folder
|
7 |
* Author: WP-Staging
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi, ilgityildirim
|
10 |
+
* Version: 2.6.8
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|
39 |
|
40 |
// Plugin Version
|
41 |
if (!defined('WPSTG_VERSION')) {
|
42 |
+
define('WPSTG_VERSION', '2.6.8');
|
43 |
}
|
44 |
|
45 |
// Compatible up to WordPress Version
|
52 |
define('WPSTG_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
53 |
}
|
54 |
|
55 |
+
// Expected version number of the must-use plugin 'optimizer'. Used for automatic updates of the mu-plugin
|
56 |
if (!defined('WPSTG_OPTIMIZER_MUVERSION')) {
|
57 |
+
define('WPSTG_OPTIMIZER_MUVERSION', 1.2);
|
58 |
}
|
59 |
|
60 |
// URL of the base folder
|