WP Staging – DB & File Duplicator & Migration - Version 2.4.6

Version Description

  • Fix: Can not login to staging site . Changed minimum user capability to 'manage_options' instead 'administrator'
Download this release

Release Info

Developer ReneHermi
Plugin Icon 128x128 WP Staging – DB & File Duplicator & Migration
Version 2.4.6
Comparing to
See all releases

Code changes from version 2.4.4 to 2.4.6

apps/Backend/Modules/SystemInfo.php CHANGED
@@ -10,7 +10,7 @@ use WPStaging\Utils\Multisite;
10
 
11
  // No Direct Access
12
  if( !defined( "WPINC" ) ) {
13
- die;
14
  }
15
 
16
  /**
@@ -19,533 +19,558 @@ if( !defined( "WPINC" ) ) {
19
  */
20
  class SystemInfo extends InjectionAware {
21
 
22
- /**
23
- * @var bool
24
- */
25
- private $isMultiSite;
26
-
27
- /**
28
- *
29
- * @var obj
30
- */
31
- private $helper;
32
-
33
- /**
34
- * Initialize class
35
- */
36
- public function initialize() {
37
- $this->isMultiSite = is_multisite();
38
- $this->helper = new Utils\Helper();
39
- }
40
-
41
- /**
42
- * Magic method
43
- * @return string
44
- */
45
- public function __toString() {
46
- return $this->get();
47
- }
48
-
49
- /**
50
- * Get System Information as text
51
- * @return string
52
- */
53
- public function get() {
54
- $output = "### Begin System Info ###" . PHP_EOL . PHP_EOL;
55
-
56
- $output .= $this->wpstaging();
57
-
58
- $output .= $this->site();
59
-
60
- $output .= $this->getMultisiteInfo();
61
-
62
- $output .= $this->browser();
63
-
64
- $output .= $this->wp();
65
-
66
- $output .= $this->plugins();
67
-
68
- $output .= $this->multiSitePlugins();
69
-
70
- $output .= $this->server();
71
-
72
- $output .= $this->php();
73
-
74
- $output .= $this->phpExtensions();
75
-
76
- $output .= PHP_EOL . "### End System Info ###";
77
-
78
- return $output;
79
- }
80
-
81
- /**
82
- * @param string $string
83
- * @return string
84
- */
85
- public function header( $string ) {
86
- return PHP_EOL . "-- {$string}" . PHP_EOL . PHP_EOL;
87
- }
88
-
89
- /**
90
- * Formating title and the value
91
- * @param string $title
92
- * @param string $value
93
- * @return string
94
- */
95
- public function info( $title, $value ) {
96
- return str_pad( $title, 56, ' ', STR_PAD_RIGHT ) . $value . PHP_EOL;
97
- }
98
-
99
- /**
100
- * Theme Information
101
- * @return string
102
- */
103
- public function theme() {
104
- // Versions earlier than 3.4
105
- if( get_bloginfo( "version" ) < "3.4" ) {
106
- $themeData = get_theme_data( get_stylesheet_directory() . "/style.css" );
107
- return "{$themeData["Name"]} {$themeData["Version"]}";
108
- }
109
-
110
- $themeData = wp_get_theme();
111
- return "{$themeData->Name} {$themeData->Version}";
112
- }
113
-
114
- /**
115
- * Site Information
116
- * @return string
117
- */
118
- public function site() {
119
- $output = "-- Site Info" . PHP_EOL . PHP_EOL;
120
- $output .= $this->info( "Site URL:", site_url() );
121
- $output .= $this->info( "Home URL:", $this->helper->get_home_url() );
122
- $output .= $this->info( "Home Path:", get_home_path() );
123
- $output .= $this->info( "ABSPATH:", ABSPATH );
124
- $output .= $this->info( "Installed in subdir:", ( $this->isSubDir() ? 'Yes' : 'No' ) );
125
-
126
- return apply_filters( "wpstg_sysinfo_after_site_info", $output );
127
- }
128
-
129
- /**
130
- * Multisite information
131
- * @return string
132
- */
133
- private function getMultisiteInfo(){
134
- if (!$this->isMultiSite){
135
- return '';
136
- }
137
-
138
- $multisite = new Multisite();
139
-
140
- $output = $this->info( "Multisite:", ($this->isMultiSite ? "Yes" : "No" ) );
141
- $output .= $this->info( "Multisite Blog ID:", get_current_blog_id() );
142
- $output .= $this->info( "MultiSite URL:", $multisite->getHomeURL() );
143
- $output .= $this->info( "MultiSite URL without scheme:", $multisite->getHomeUrlWithoutScheme() );
144
- $output .= $this->info( "MultiSite is Main Site:", is_main_site() ? 'Yes' : 'No' );
145
-
146
- return apply_filters( "wpstg_sysinfo_after_multisite_info", $output );
147
-
148
-
149
- }
150
-
151
-
152
- /**
153
- * Wp Staging plugin Information
154
- * @return string
155
- */
156
- public function wpstaging() {
157
- // Get wpstg settings
158
- $settings = ( object ) get_option( 'wpstg_settings', array() );
159
-
160
- // Clones data < 1.1.6.x
161
- $clones = ( object ) get_option( 'wpstg_existing_clones', array() );
162
- // Clones data version > 2.x
163
- $clonesBeta = get_option( 'wpstg_existing_clones_beta', array() );
164
-
165
-
166
- $output = "-- WP Staging Settings" . PHP_EOL . PHP_EOL;
167
- $output .= $this->info( "Query Limit:", isset( $settings->queryLimit ) ? $settings->queryLimit : 'undefined' );
168
- $output .= $this->info( "DB Search & Replace Limit:", isset( $settings->querySRLimit ) ? $settings->querySRLimit : 'undefined' );
169
- $output .= $this->info( "File Copy Limit:", isset( $settings->fileLimit ) ? $settings->fileLimit : 'undefined' );
170
- $output .= $this->info( "Batch Size:", isset( $settings->batchSize ) ? $settings->batchSize : 'undefined' );
171
- $output .= $this->info( "CPU Load:", isset( $settings->cpuLoad ) ? $settings->cpuLoad : 'undefined' );
172
- $output .= $this->info( "WP in Subdir:", $this->isSubDir() ? 'true' : 'false' );
173
-
174
- $output .= PHP_EOL . PHP_EOL . "-- Available Sites Version < 1.1.6.x" . PHP_EOL . PHP_EOL;
175
-
176
- foreach ( $clones as $key => $value ) {
177
- $output .= $this->info( "Site name & subfolder :", $value );
178
- }
179
- $output .= PHP_EOL . PHP_EOL . "-- Available Sites Version > 2.0.x" . PHP_EOL . PHP_EOL;
180
-
181
- foreach ( $clonesBeta as $key => $clone ) {
182
- $output .= $this->info( "Number:", isset( $clone['number'] ) ? $clone['number'] : 'undefined' );
183
- $output .= $this->info( "directoryName:", isset( $clone['directoryName'] ) ? $clone['directoryName'] : 'undefined' );
184
- $output .= $this->info( "Path:", isset( $clone['path'] ) ? $clone['path'] : 'undefined' );
185
- $output .= $this->info( "URL:", isset( $clone['url'] ) ? $clone['url'] : 'undefined' );
186
- $output .= $this->info( "DB Prefix:", isset( $clone['prefix'] ) ? $clone['prefix'] : 'undefined' );
187
- $output .= $this->info( "DB Prefix wp-config.php:", $this->getStagingPrefix( $clone ) );
188
- $output .= $this->info( "Version:", isset( $clone['version'] ) ? $clone['version'] : 'undefined' ) . PHP_EOL . PHP_EOL;
189
- }
190
-
191
-
192
- $output .= $this->info( "Raw Clones Data:", json_encode( get_option( 'wpstg_existing_clones_beta', 'undefined' ) ) );
193
-
194
- $output .= '' . PHP_EOL;
195
-
196
-
197
- //$output .= PHP_EOL . PHP_EOL;
198
-
199
- $output .= $this->info( "Plugin Version:", get_option( 'wpstg_version', 'undefined' ) );
200
- $output .= $this->info( "Install Date:", get_option( 'wpstg_installDate', 'undefined' ) );
201
- $output .= $this->info( "Upgraded from:", get_option( 'wpstg_version_upgraded_from', 'undefined' ) );
202
- $output .= $this->info( "Is Staging Site:", get_option( 'wpstg_is_staging_site', 'undefined' ) ) . PHP_EOL . PHP_EOL;
203
-
204
-
205
- return apply_filters( "wpstg_sysinfo_after_wpstaging_info", $output );
206
- }
207
-
208
- /**
209
- * Browser Information
210
- * @return string
211
- */
212
- public function browser() {
213
- $output = $this->header( "User Browser" );
214
- $output .= (new Browser);
215
-
216
- return apply_filters( "wpstg_sysinfo_after_user_browser", $output );
217
- }
218
-
219
- /**
220
- * Frontpage Information when frontpage is set to "page"
221
- * @return string
222
- */
223
- public function frontPage() {
224
- if( get_option( "show_on_front" ) !== "page" ) {
225
- return '';
226
- }
227
-
228
- $frontPageID = get_option( "page_on_front" );
229
- $blogPageID = get_option( "page_for_posts" );
230
-
231
- // Front Page
232
- $pageFront = ($frontPageID != 0) ? get_the_title( $frontPageID ) . " (#{$frontPageID})" : "Unset";
233
- // Blog Page ID
234
- $pageBlog = ($blogPageID != 0) ? get_the_title( $blogPageID ) . " (#{$blogPageID})" : "Unset";
235
-
236
- $output = $this->info( "Page On Front:", $pageFront );
237
- $output .= $this->info( "Page For Posts:", $pageBlog );
238
-
239
- return $output;
240
- }
241
-
242
- /**
243
- * Check wp_remote_post() functionality
244
- * @return string
245
- */
246
- public function wpRemotePost() {
247
- // Make sure wp_remote_post() is working
248
- $wpRemotePost = "wp_remote_post() does not work";
249
-
250
- // Send request
251
- $response = wp_remote_post(
252
- "https://www.paypal.com/cgi-bin/webscr", array(
253
- "sslverify" => false,
254
- "timeout" => 60,
255
- "user-agent" => "WPSTG/" . WPStaging::VERSION,
256
- "body" => array("cmd" => "_notify-validate")
257
- )
258
- );
259
-
260
- // Validate it worked
261
- if( !is_wp_error( $response ) && 200 <= $response["response"]["code"] && 300 > $response["response"]["code"] ) {
262
- $wpRemotePost = "wp_remote_post() works";
263
- }
264
-
265
- return $this->info( "Remote Post:", $wpRemotePost );
266
- }
267
-
268
- /**
269
- * WordPress Configuration
270
- * @return string
271
- */
272
- public function wp() {
273
- $output = $this->header( "WordPress Configuration" );
274
- $output .= $this->info( "Version:", get_bloginfo( "version" ) );
275
- $output .= $this->info( "Language:", (defined( "WPLANG" ) && WPLANG) ? WPLANG : "en_US" );
276
-
277
- $permalinkStructure = get_option( "permalink_structure" );
278
- ;
279
- $output .= $this->info( "Permalink Structure:", ($permalinkStructure) ? $permalinkStructure : "Default" );
280
-
281
- $output .= $this->info( "Active Theme:", $this->theme() );
282
- $output .= $this->info( "Show On Front:", get_option( "show_on_front" ) );
283
-
284
- // Frontpage information
285
- $output .= $this->frontPage();
286
-
287
- // WP Remote Post
288
- $output .= $this->wpRemotePost();
289
-
290
- // Table Prefix
291
- $wpDB = $this->di->get( "wpdb" );
292
- $tablePrefix = "DB Prefix: " . $wpDB->prefix . ' ';
293
- $tablePrefix .= "Length: " . strlen( $wpDB->prefix ) . " Status: ";
294
- $tablePrefix .= (strlen( $wpDB->prefix ) > 16) ? " ERROR: Too long" : " Acceptable";
295
-
296
- $output .= $this->info( "Table Prefix:", $tablePrefix );
297
-
298
- // Constants
299
- $output .= $this->info( "WP Content Path:", WP_CONTENT_DIR );
300
- $output .= $this->info( "WP Plugin Dir:", WP_PLUGIN_DIR );
301
- if( defined( 'UPLOADS' ) )
302
- $output .= $this->info( "WP UPLOADS CONST:", UPLOADS );
303
- $uploads = wp_upload_dir();
304
- $output .= $this->info( "WP Uploads Dir:", $uploads['basedir'] );
305
- if( defined( 'WP_TEMP_DIR' ) )
306
- $output .= $this->info( "WP Temp Dir:", WP_TEMP_DIR );
307
-
308
- // WP Debug
309
- $output .= $this->info( "WP_DEBUG:", (defined( "WP_DEBUG" )) ? WP_DEBUG ? "Enabled" : "Disabled" : "Not set" );
310
- $output .= $this->info( "Memory Limit:", WP_MEMORY_LIMIT );
311
- $output .= $this->info( "Registered Post Stati:", implode( ", ", \get_post_stati() ) );
312
-
313
- return apply_filters( "wpstg_sysinfo_after_wpstg_config", $output );
314
- }
315
-
316
- /**
317
- * List of Active Plugins
318
- * @param array $plugins
319
- * @param array $activePlugins
320
- * @return string
321
- */
322
- public function activePlugins( $plugins, $activePlugins ) {
323
- $output = $this->header( "WordPress Active Plugins" );
324
-
325
- foreach ( $plugins as $path => $plugin ) {
326
- if( !in_array( $path, $activePlugins ) ) {
327
- continue;
328
- }
329
-
330
- $output .= "{$plugin["Name"]}: {$plugin["Version"]}" . PHP_EOL;
331
- }
332
-
333
- return apply_filters( "wpstg_sysinfo_after_wordpress_plugins", $output );
334
- }
335
-
336
- /**
337
- * List of Inactive Plugins
338
- * @param array $plugins
339
- * @param array $activePlugins
340
- * @return string
341
- */
342
- public function inactivePlugins( $plugins, $activePlugins ) {
343
- $output = $this->header( "WordPress Inactive Plugins" );
344
-
345
- foreach ( $plugins as $path => $plugin ) {
346
- if( in_array( $path, $activePlugins ) ) {
347
- continue;
348
- }
349
-
350
- $output .= "{$plugin["Name"]}: {$plugin["Version"]}" . PHP_EOL;
351
- }
352
-
353
- return apply_filters( "wpstg_sysinfo_after_wordpress_plugins_inactive", $output );
354
- }
355
-
356
- /**
357
- * Get list of active and inactive plugins
358
- * @return string
359
- */
360
- public function plugins() {
361
- // Get plugins and active plugins
362
- $plugins = get_plugins();
363
- $activePlugins = get_option( "active_plugins", array() );
364
-
365
- // Active plugins
366
- $output = $this->activePlugins( $plugins, $activePlugins );
367
- $output .= $this->inactivePlugins( $plugins, $activePlugins );
368
-
369
- return $output;
370
- }
371
-
372
- /**
373
- * Multisite Plugins
374
- * @return string
375
- */
376
- public function multiSitePlugins() {
377
- if( !$this->isMultiSite ) {
378
- return '';
379
- }
380
-
381
- $output = $this->header( "Network Active Plugins" );
382
-
383
- $plugins = wp_get_active_network_plugins();
384
- $activePlugins = get_site_option( "active_sitewide_plugins", array() );
385
-
386
- foreach ( $plugins as $pluginPath ) {
387
- $pluginBase = plugin_basename( $pluginPath );
388
-
389
- if( !array_key_exists( $pluginBase, $activePlugins ) ) {
390
- continue;
391
- }
392
-
393
- $plugin = get_plugin_data( $pluginPath );
394
-
395
- $output .= "{$plugin["Name"]}: {$plugin["Version"]}" . PHP_EOL;
396
- }
397
- unset( $plugins, $activePlugins );
398
-
399
- return $output;
400
- }
401
-
402
- /**
403
- * Server Information
404
- * @return string
405
- */
406
- public function server() {
407
- // Server Configuration
408
- $output = $this->header( "Webserver Configuration" );
409
-
410
- $output .= $this->info( "PHP Version:", PHP_VERSION );
411
- $output .= $this->info( "MySQL Version:", $this->di->get( "wpdb" )->db_version() );
412
- $output .= $this->info( "Webserver Info:", $_SERVER["SERVER_SOFTWARE"] );
413
-
414
- return apply_filters( "wpstg_sysinfo_after_webserver_config", $output );
415
- }
416
-
417
- /**
418
- * PHP Configuration
419
- * @return string
420
- */
421
- public function php() {
422
- $output = $this->header( "PHP Configuration" );
423
- $output .= $this->info( "Safe Mode:", ($this->isSafeModeEnabled() ? "Enabled" : "Disabled" ) );
424
- $output .= $this->info( "Memory Limit:", ini_get( "memory_limit" ) );
425
- $output .= $this->info( "Upload Max Size:", ini_get( "upload_max_filesize" ) );
426
- $output .= $this->info( "Post Max Size:", ini_get( "post_max_size" ) );
427
- $output .= $this->info( "Upload Max Filesize:", ini_get( "upload_max_filesize" ) );
428
- $output .= $this->info( "Time Limit:", ini_get( "max_execution_time" ) );
429
- $output .= $this->info( "Max Input Vars:", ini_get( "max_input_vars" ) );
430
-
431
- $displayErrors = ini_get( "display_errors" );
432
- $output .= $this->info( "Display Errors:", ($displayErrors) ? "On ({$displayErrors})" : "N/A" );
433
-
434
- return apply_filters( "wpstg_sysinfo_after_php_config", $output );
435
- }
436
-
437
- /**
438
- * Check if PHP is on Safe Mode
439
- * @return bool
440
- */
441
- public function isSafeModeEnabled() {
442
- return (
443
- version_compare( PHP_VERSION, "5.4.0", '<' ) &&
444
- @ini_get( "safe_mode" )
445
- );
446
- }
447
-
448
- /**
449
- * Checks if function exists or not
450
- * @param string $functionName
451
- * @return string
452
- */
453
- public function isSupported( $functionName ) {
454
- return (function_exists( $functionName )) ? "Supported" : "Not Supported";
455
- }
456
-
457
- /**
458
- * Checks if class or extension is loaded / exists to determine if it is installed or not
459
- * @param string $name
460
- * @param bool $isClass
461
- * @return string
462
- */
463
- public function isInstalled( $name, $isClass = true ) {
464
- if( true === $isClass ) {
465
- return (class_exists( $name )) ? "Installed" : "Not Installed";
466
- } else {
467
- return (extension_loaded( $name )) ? "Installed" : "Not Installed";
468
- }
469
- }
470
-
471
- /**
472
- * Gets Installed Important PHP Extensions
473
- * @return string
474
- */
475
- public function phpExtensions() {
476
- // Important PHP Extensions
477
- $version = curl_version();
478
-
479
- $bitfields = Array(
480
- 'CURL_VERSION_IPV6',
481
- 'CURL_VERSION_KERBEROS4',
482
- 'CURL_VERSION_SSL',
483
- 'CURL_VERSION_LIBZ'
484
- );
485
-
486
- $output = $this->header( "PHP Extensions" );
487
- $output .= $this->info( "cURL:", $this->isSupported( "curl_init" ) );
488
- $output .= $this->info( "cURL version:", $version['version'] );
489
- $output .= $this->info( "cURL ssl version number:", $version['ssl_version'] );
490
- $output .= $this->info( "cURL host:", $version['host'] );
491
- foreach ( $version['protocols'] as $protocols ) {
492
- $output .= $this->info( "cURL protocols:", $protocols );
493
- }
494
- foreach ( $bitfields as $feature ) {
495
- $output .= $feature . ($version['features'] & constant( $feature ) ? ' yes' : ' no') . PHP_EOL;
496
- }
497
-
498
-
499
- $output .= $this->info( "fsockopen:", $this->isSupported( "fsockopen" ) );
500
- $output .= $this->info( "SOAP Client:", $this->isInstalled( "SoapClient" ) );
501
- $output .= $this->info( "Suhosin:", $this->isInstalled( "suhosin", false ) );
502
-
503
- return apply_filters( "wpstg_sysinfo_after_php_ext", $output );
504
- }
505
-
506
- /**
507
- * Check if WP is installed in subdir
508
- * @return boolean
509
- */
510
- private function isSubDir() {
511
- // Compare names without scheme to bypass cases where siteurl and home have different schemes http / https
512
- // This is happening much more often than you would expect
513
- $siteurl = preg_replace( '#^https?://#', '', rtrim( get_option( 'siteurl' ), '/' ) );
514
- $home = preg_replace( '#^https?://#', '', rtrim( get_option( 'home' ), '/' ) );
515
-
516
- if( $home !== $siteurl ) {
517
- return true;
518
- }
519
- return false;
520
- }
521
-
522
- /**
523
- * Check and return prefix of the staging site
524
- */
525
-
526
- /**
527
- * Try to get the staging prefix from wp-config.php of staging site
528
- * @param array $clone
529
- * @return sting
530
- */
531
- private function getStagingPrefix( $clone = array() ) {
532
- // Throw error
533
- $path = ABSPATH . $clone['directoryName'] . DIRECTORY_SEPARATOR . "wp-config.php";
534
- if( false === ($content = @file_get_contents( $path )) ) {
535
- return 'Can\'t find staging wp-config.php';
536
- } else {
537
-
538
- // Get prefix from wp-config.php
539
- //preg_match_all("/table_prefix\s*=\s*'(\w*)';/", $content, $matches);
540
- preg_match( "/table_prefix\s*=\s*'(\w*)';/", $content, $matches );
541
- //wp_die(var_dump($matches));
542
-
543
- if( !empty( $matches[1] ) ) {
544
- return $matches[1];
545
- } else {
546
- return 'No table_prefix in wp-config.php';
547
- }
548
- }
549
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
550
 
551
  }
10
 
11
  // No Direct Access
12
  if( !defined( "WPINC" ) ) {
13
+ die;
14
  }
15
 
16
  /**
19
  */
20
  class SystemInfo extends InjectionAware {
21
 
22
+ /**
23
+ * @var bool
24
+ */
25
+ private $isMultiSite;
26
+
27
+ /**
28
+ *
29
+ * @var obj
30
+ */
31
+ private $helper;
32
+
33
+ /**
34
+ * Initialize class
35
+ */
36
+ public function initialize() {
37
+ $this->isMultiSite = is_multisite();
38
+ $this->helper = new Utils\Helper();
39
+ }
40
+
41
+ /**
42
+ * Magic method
43
+ * @return string
44
+ */
45
+ public function __toString() {
46
+ return $this->get();
47
+ }
48
+
49
+ /**
50
+ * Get System Information as text
51
+ * @return string
52
+ */
53
+ public function get() {
54
+ $output = "### Begin System Info ###" . PHP_EOL . PHP_EOL;
55
+
56
+ $output .= $this->wpstaging();
57
+
58
+ $output .= $this->wp();
59
+
60
+ $output .= $this->site();
61
+
62
+ $output .= $this->getMultisiteInfo();
63
+
64
+ $output .= $this->plugins();
65
+
66
+ $output .= $this->multiSitePlugins();
67
+
68
+ $output .= $this->server();
69
+
70
+ $output .= $this->php();
71
+
72
+ $output .= $this->phpExtensions();
73
+
74
+ $output .= $this->browser();
75
+
76
+ $output .= PHP_EOL . "### End System Info ###";
77
+
78
+ return $output;
79
+ }
80
+
81
+ /**
82
+ * @param string $string
83
+ * @return string
84
+ */
85
+ public function header( $string ) {
86
+ return PHP_EOL . "-- {$string}" . PHP_EOL . PHP_EOL;
87
+ }
88
+
89
+ /**
90
+ * Formating title and the value
91
+ * @param string $title
92
+ * @param string $value
93
+ * @return string
94
+ */
95
+ public function info( $title, $value ) {
96
+ return str_pad( $title, 56, ' ', STR_PAD_RIGHT ) . $value . PHP_EOL;
97
+ }
98
+
99
+ /**
100
+ * Theme Information
101
+ * @return string
102
+ */
103
+ public function theme() {
104
+ // Versions earlier than 3.4
105
+ if( get_bloginfo( "version" ) < "3.4" ) {
106
+ $themeData = get_theme_data( get_stylesheet_directory() . "/style.css" );
107
+ return "{$themeData["Name"]} {$themeData["Version"]}";
108
+ }
109
+
110
+ $themeData = wp_get_theme();
111
+ return "{$themeData->Name} {$themeData->Version}";
112
+ }
113
+
114
+ /**
115
+ * Site Information
116
+ * @return string
117
+ */
118
+ public function site() {
119
+ $output = $this->header( "-- Site Info" );
120
+ $output .= $this->info( "Site URL:", site_url() );
121
+ $output .= $this->info( "Home URL:", $this->helper->get_home_url() );
122
+ $output .= $this->info( "Home Path:", get_home_path() );
123
+ $output .= $this->info( "ABSPATH:", ABSPATH );
124
+ $output .= $this->info( "Installed in subdir:", ( $this->isSubDir() ? 'Yes' : 'No' ) );
125
+
126
+ return apply_filters( "wpstg_sysinfo_after_site_info", $output );
127
+ }
128
+
129
+ /**
130
+ * Multisite information
131
+ * @return string
132
+ */
133
+ private function getMultisiteInfo() {
134
+ if( !$this->isMultiSite ) {
135
+ return '';
136
+ }
137
+
138
+ $multisite = new Multisite();
139
+
140
+ $output = $this->info( "Multisite:", ($this->isMultiSite ? "Yes" : "No" ) );
141
+ $output .= $this->info( "Multisite Blog ID:", get_current_blog_id() );
142
+ $output .= $this->info( "MultiSite URL:", $multisite->getHomeURL() );
143
+ $output .= $this->info( "MultiSite URL without scheme:", $multisite->getHomeUrlWithoutScheme() );
144
+ $output .= $this->info( "MultiSite is Main Site:", is_main_site() ? 'Yes' : 'No' );
145
+
146
+ return apply_filters( "wpstg_sysinfo_after_multisite_info", $output );
147
+ }
148
+
149
+ /**
150
+ * Wp Staging plugin Information
151
+ * @return string
152
+ */
153
+ public function wpstaging() {
154
+ // Get wpstg settings
155
+ $settings = ( object ) get_option( 'wpstg_settings', array() );
156
+
157
+ // Clones data < 1.1.6.x
158
+ $clones = ( object ) get_option( 'wpstg_existing_clones', array() );
159
+ // Clones data version > 2.x
160
+ $clonesBeta = get_option( 'wpstg_existing_clones_beta', array() );
161
+
162
+
163
+ $output = "-- WP Staging Settings" . PHP_EOL . PHP_EOL;
164
+ $output .= $this->info( "Query Limit:", isset( $settings->queryLimit ) ? $settings->queryLimit : 'undefined' );
165
+ $output .= $this->info( "DB Search & Replace Limit:", isset( $settings->querySRLimit ) ? $settings->querySRLimit : 'undefined' );
166
+ $output .= $this->info( "File Copy Limit:", isset( $settings->fileLimit ) ? $settings->fileLimit : 'undefined' );
167
+ $output .= $this->info( "Batch Size:", isset( $settings->batchSize ) ? $settings->batchSize : 'undefined' );
168
+ $output .= $this->info( "CPU Load:", isset( $settings->cpuLoad ) ? $settings->cpuLoad : 'undefined' );
169
+ $output .= $this->info( "WP in Subdir:", $this->isSubDir() ? 'true' : 'false' );
170
+
171
+ $output .= PHP_EOL . PHP_EOL . "-- Available Sites Version < 1.1.6.x" . PHP_EOL . PHP_EOL;
172
+
173
+ foreach ( $clones as $key => $value ) {
174
+ $output .= $this->info( "Site name & subfolder :", $value );
175
+ }
176
+ $output .= PHP_EOL . PHP_EOL . "-- Available Sites Version > 2.0.x" . PHP_EOL . PHP_EOL;
177
+
178
+ foreach ( $clonesBeta as $key => $clone ) {
179
+
180
+ $path = !empty( $clone['path'] ) ? $clone['path'] : 'undefined';
181
+
182
+ $output .= $this->info( "Number:", isset( $clone['number'] ) ? $clone['number'] : 'undefined' );
183
+ $output .= $this->info( "directoryName:", isset( $clone['directoryName'] ) ? $clone['directoryName'] : 'undefined' );
184
+ $output .= $this->info( "Path:", $path );
185
+ $output .= $this->info( "URL:", isset( $clone['url'] ) ? $clone['url'] : 'undefined' );
186
+ $output .= $this->info( "DB Prefix:", isset( $clone['prefix'] ) ? $clone['prefix'] : 'undefined' );
187
+ $output .= $this->info( "DB Prefix wp-config.php:", $this->getStagingPrefix( $clone ) );
188
+ $output .= $this->info( "WP Staging Version:", isset( $clone['version'] ) ? $clone['version'] : 'undefined' );
189
+ $output .= $this->info( "WP Version:", $this->getStagingWpVersion($path)) . PHP_EOL . PHP_EOL;
190
+ }
191
+
192
+
193
+ $output .= $this->info( "Raw Clones Data:", json_encode( get_option( 'wpstg_existing_clones_beta', 'undefined' ) ) );
194
+
195
+ $output .= '' . PHP_EOL;
196
+
197
+
198
+ //$output .= PHP_EOL . PHP_EOL;
199
+
200
+ $output .= $this->info( "Plugin Version:", get_option( 'wpstg_version', 'undefined' ) );
201
+ $output .= $this->info( "Install Date:", get_option( 'wpstg_installDate', 'undefined' ) );
202
+ $output .= $this->info( "Upgraded from:", get_option( 'wpstg_version_upgraded_from', 'undefined' ) );
203
+ $output .= $this->info( "Is Staging Site:", get_option( 'wpstg_is_staging_site', 'undefined' ) ) . PHP_EOL . PHP_EOL;
204
+
205
+
206
+ return apply_filters( "wpstg_sysinfo_after_wpstaging_info", $output );
207
+ }
208
+
209
+ /**
210
+ * Browser Information
211
+ * @return string
212
+ */
213
+ public function browser() {
214
+ $output = $this->header( "User Browser" );
215
+ $output .= (new Browser);
216
+
217
+ return apply_filters( "wpstg_sysinfo_after_user_browser", $output );
218
+ }
219
+
220
+ /**
221
+ * Frontpage Information when frontpage is set to "page"
222
+ * @return string
223
+ */
224
+ public function frontPage() {
225
+ if( get_option( "show_on_front" ) !== "page" ) {
226
+ return '';
227
+ }
228
+
229
+ $frontPageID = get_option( "page_on_front" );
230
+ $blogPageID = get_option( "page_for_posts" );
231
+
232
+ // Front Page
233
+ $pageFront = ($frontPageID != 0) ? get_the_title( $frontPageID ) . " (#{$frontPageID})" : "Unset";
234
+ // Blog Page ID
235
+ $pageBlog = ($blogPageID != 0) ? get_the_title( $blogPageID ) . " (#{$blogPageID})" : "Unset";
236
+
237
+ $output = $this->info( "Page On Front:", $pageFront );
238
+ $output .= $this->info( "Page For Posts:", $pageBlog );
239
+
240
+ return $output;
241
+ }
242
+
243
+ /**
244
+ * Check wp_remote_post() functionality
245
+ * @return string
246
+ */
247
+ public function wpRemotePost() {
248
+ // Make sure wp_remote_post() is working
249
+ $wpRemotePost = "wp_remote_post() does not work";
250
+
251
+ // Send request
252
+ $response = wp_remote_post(
253
+ "https://www.paypal.com/cgi-bin/webscr", array(
254
+ "sslverify" => false,
255
+ "timeout" => 60,
256
+ "user-agent" => "WPSTG/" . WPStaging::VERSION,
257
+ "body" => array("cmd" => "_notify-validate")
258
+ )
259
+ );
260
+
261
+ // Validate it worked
262
+ if( !is_wp_error( $response ) && 200 <= $response["response"]["code"] && 300 > $response["response"]["code"] ) {
263
+ $wpRemotePost = "wp_remote_post() works";
264
+ }
265
+
266
+ return $this->info( "Remote Post:", $wpRemotePost );
267
+ }
268
+
269
+ /**
270
+ * WordPress Configuration
271
+ * @return string
272
+ */
273
+ public function wp() {
274
+ $output = $this->header( "WordPress Configuration" );
275
+ $output .= $this->info( "Version:", get_bloginfo( "version" ) );
276
+ $output .= $this->info( "Language:", (defined( "WPLANG" ) && WPLANG) ? WPLANG : "en_US" );
277
+
278
+ $permalinkStructure = get_option( "permalink_structure" );
279
+ ;
280
+ $output .= $this->info( "Permalink Structure:", ($permalinkStructure) ? $permalinkStructure : "Default" );
281
+
282
+ $output .= $this->info( "Active Theme:", $this->theme() );
283
+ $output .= $this->info( "Show On Front:", get_option( "show_on_front" ) );
284
+
285
+ // Frontpage information
286
+ $output .= $this->frontPage();
287
+
288
+ // WP Remote Post
289
+ $output .= $this->wpRemotePost();
290
+
291
+ // Table Prefix
292
+ $wpDB = $this->di->get( "wpdb" );
293
+ $tablePrefix = "DB Prefix: " . $wpDB->prefix . ' ';
294
+ $tablePrefix .= "Length: " . strlen( $wpDB->prefix ) . " Status: ";
295
+ $tablePrefix .= (strlen( $wpDB->prefix ) > 16) ? " ERROR: Too long" : " Acceptable";
296
+
297
+ $output .= $this->info( "Table Prefix:", $tablePrefix );
298
+
299
+ // Constants
300
+ $output .= $this->info( "WP Content Path:", WP_CONTENT_DIR );
301
+ $output .= $this->info( "WP Plugin Dir:", WP_PLUGIN_DIR );
302
+ if( defined( 'UPLOADS' ) )
303
+ $output .= $this->info( "WP UPLOADS CONST:", UPLOADS );
304
+ $uploads = wp_upload_dir();
305
+ $output .= $this->info( "WP Uploads Dir:", $uploads['basedir'] );
306
+ if( defined( 'WP_TEMP_DIR' ) )
307
+ $output .= $this->info( "WP Temp Dir:", WP_TEMP_DIR );
308
+
309
+ // WP Debug
310
+ $output .= $this->info( "WP_DEBUG:", (defined( "WP_DEBUG" )) ? WP_DEBUG ? "Enabled" : "Disabled" : "Not set" );
311
+ $output .= $this->info( "Memory Limit:", WP_MEMORY_LIMIT );
312
+ $output .= $this->info( "Registered Post Stati:", implode( ", ", \get_post_stati() ) );
313
+
314
+ return apply_filters( "wpstg_sysinfo_after_wpstg_config", $output );
315
+ }
316
+
317
+ /**
318
+ * List of Active Plugins
319
+ * @param array $plugins
320
+ * @param array $activePlugins
321
+ * @return string
322
+ */
323
+ public function activePlugins( $plugins, $activePlugins ) {
324
+ $output = $this->header( "WordPress Active Plugins" );
325
+
326
+ foreach ( $plugins as $path => $plugin ) {
327
+ if( !in_array( $path, $activePlugins ) ) {
328
+ continue;
329
+ }
330
+
331
+ $output .= "{$plugin["Name"]}: {$plugin["Version"]}" . PHP_EOL;
332
+ }
333
+
334
+ return apply_filters( "wpstg_sysinfo_after_wordpress_plugins", $output );
335
+ }
336
+
337
+ /**
338
+ * List of Inactive Plugins
339
+ * @param array $plugins
340
+ * @param array $activePlugins
341
+ * @return string
342
+ */
343
+ public function inactivePlugins( $plugins, $activePlugins ) {
344
+ $output = $this->header( "WordPress Inactive Plugins" );
345
+
346
+ foreach ( $plugins as $path => $plugin ) {
347
+ if( in_array( $path, $activePlugins ) ) {
348
+ continue;
349
+ }
350
+
351
+ $output .= "{$plugin["Name"]}: {$plugin["Version"]}" . PHP_EOL;
352
+ }
353
+
354
+ return apply_filters( "wpstg_sysinfo_after_wordpress_plugins_inactive", $output );
355
+ }
356
+
357
+ /**
358
+ * Get list of active and inactive plugins
359
+ * @return string
360
+ */
361
+ public function plugins() {
362
+ // Get plugins and active plugins
363
+ $plugins = get_plugins();
364
+ $activePlugins = get_option( "active_plugins", array() );
365
+
366
+ // Active plugins
367
+ $output = $this->activePlugins( $plugins, $activePlugins );
368
+ $output .= $this->inactivePlugins( $plugins, $activePlugins );
369
+
370
+ return $output;
371
+ }
372
+
373
+ /**
374
+ * Multisite Plugins
375
+ * @return string
376
+ */
377
+ public function multiSitePlugins() {
378
+ if( !$this->isMultiSite ) {
379
+ return '';
380
+ }
381
+
382
+ $output = $this->header( "Network Active Plugins" );
383
+
384
+ $plugins = wp_get_active_network_plugins();
385
+ $activePlugins = get_site_option( "active_sitewide_plugins", array() );
386
+
387
+ foreach ( $plugins as $pluginPath ) {
388
+ $pluginBase = plugin_basename( $pluginPath );
389
+
390
+ if( !array_key_exists( $pluginBase, $activePlugins ) ) {
391
+ continue;
392
+ }
393
+
394
+ $plugin = get_plugin_data( $pluginPath );
395
+
396
+ $output .= "{$plugin["Name"]}: {$plugin["Version"]}" . PHP_EOL;
397
+ }
398
+ unset( $plugins, $activePlugins );
399
+
400
+ return $output;
401
+ }
402
+
403
+ /**
404
+ * Server Information
405
+ * @return string
406
+ */
407
+ public function server() {
408
+ // Server Configuration
409
+ $output = $this->header( "Webserver Configuration" );
410
+
411
+ $output .= $this->info( "PHP Version:", PHP_VERSION );
412
+ $output .= $this->info( "MySQL Version:", $this->di->get( "wpdb" )->db_version() );
413
+ $output .= $this->info( "Webserver Info:", $_SERVER["SERVER_SOFTWARE"] );
414
+
415
+ return apply_filters( "wpstg_sysinfo_after_webserver_config", $output );
416
+ }
417
+
418
+ /**
419
+ * PHP Configuration
420
+ * @return string
421
+ */
422
+ public function php() {
423
+ $output = $this->header( "PHP Configuration" );
424
+ $output .= $this->info( "Safe Mode:", ($this->isSafeModeEnabled() ? "Enabled" : "Disabled" ) );
425
+ $output .= $this->info( "Memory Limit:", ini_get( "memory_limit" ) );
426
+ $output .= $this->info( "Upload Max Size:", ini_get( "upload_max_filesize" ) );
427
+ $output .= $this->info( "Post Max Size:", ini_get( "post_max_size" ) );
428
+ $output .= $this->info( "Upload Max Filesize:", ini_get( "upload_max_filesize" ) );
429
+ $output .= $this->info( "Time Limit:", ini_get( "max_execution_time" ) );
430
+ $output .= $this->info( "Max Input Vars:", ini_get( "max_input_vars" ) );
431
+
432
+ $displayErrors = ini_get( "display_errors" );
433
+ $output .= $this->info( "Display Errors:", ($displayErrors) ? "On ({$displayErrors})" : "N/A" );
434
+
435
+ return apply_filters( "wpstg_sysinfo_after_php_config", $output );
436
+ }
437
+
438
+ /**
439
+ * Check if PHP is on Safe Mode
440
+ * @return bool
441
+ */
442
+ public function isSafeModeEnabled() {
443
+ return (
444
+ version_compare( PHP_VERSION, "5.4.0", '<' ) &&
445
+ @ini_get( "safe_mode" )
446
+ );
447
+ }
448
+
449
+ /**
450
+ * Checks if function exists or not
451
+ * @param string $functionName
452
+ * @return string
453
+ */
454
+ public function isSupported( $functionName ) {
455
+ return (function_exists( $functionName )) ? "Supported" : "Not Supported";
456
+ }
457
+
458
+ /**
459
+ * Checks if class or extension is loaded / exists to determine if it is installed or not
460
+ * @param string $name
461
+ * @param bool $isClass
462
+ * @return string
463
+ */
464
+ public function isInstalled( $name, $isClass = true ) {
465
+ if( true === $isClass ) {
466
+ return (class_exists( $name )) ? "Installed" : "Not Installed";
467
+ } else {
468
+ return (extension_loaded( $name )) ? "Installed" : "Not Installed";
469
+ }
470
+ }
471
+
472
+ /**
473
+ * Gets Installed Important PHP Extensions
474
+ * @return string
475
+ */
476
+ public function phpExtensions() {
477
+ // Important PHP Extensions
478
+ $version = curl_version();
479
+
480
+ $bitfields = Array(
481
+ 'CURL_VERSION_IPV6',
482
+ 'CURL_VERSION_KERBEROS4',
483
+ 'CURL_VERSION_SSL',
484
+ 'CURL_VERSION_LIBZ'
485
+ );
486
+
487
+ $output = $this->header( "PHP Extensions" );
488
+ $output .= $this->info( "cURL:", $this->isSupported( "curl_init" ) );
489
+ $output .= $this->info( "cURL version:", $version['version'] );
490
+ $output .= $this->info( "cURL ssl version number:", $version['ssl_version'] );
491
+ $output .= $this->info( "cURL host:", $version['host'] );
492
+ foreach ( $version['protocols'] as $protocols ) {
493
+ $output .= $this->info( "cURL protocols:", $protocols );
494
+ }
495
+ foreach ( $bitfields as $feature ) {
496
+ $output .= $feature . ($version['features'] & constant( $feature ) ? ' yes' : ' no') . PHP_EOL;
497
+ }
498
+
499
+
500
+ $output .= $this->info( "fsockopen:", $this->isSupported( "fsockopen" ) );
501
+ $output .= $this->info( "SOAP Client:", $this->isInstalled( "SoapClient" ) );
502
+ $output .= $this->info( "Suhosin:", $this->isInstalled( "suhosin", false ) );
503
+
504
+ return apply_filters( "wpstg_sysinfo_after_php_ext", $output );
505
+ }
506
+
507
+ /**
508
+ * Check if WP is installed in subdir
509
+ * @return boolean
510
+ */
511
+ private function isSubDir() {
512
+ // Compare names without scheme to bypass cases where siteurl and home have different schemes http / https
513
+ // This is happening much more often than you would expect
514
+ $siteurl = preg_replace( '#^https?://#', '', rtrim( get_option( 'siteurl' ), '/' ) );
515
+ $home = preg_replace( '#^https?://#', '', rtrim( get_option( 'home' ), '/' ) );
516
+
517
+ if( $home !== $siteurl ) {
518
+ return true;
519
+ }
520
+ return false;
521
+ }
522
+
523
+ /**
524
+ * Check and return prefix of the staging site
525
+ */
526
+
527
+ /**
528
+ * Try to get the staging prefix from wp-config.php of staging site
529
+ * @param array $clone
530
+ * @return sting
531
+ */
532
+ private function getStagingPrefix( $clone = array() ) {
533
+ // Throw error
534
+ $path = ABSPATH . $clone['directoryName'] . DIRECTORY_SEPARATOR . "wp-config.php";
535
+ if( false === ($content = @file_get_contents( $path )) ) {
536
+ return 'Can\'t find staging wp-config.php';
537
+ } else {
538
+
539
+ // Get prefix from wp-config.php
540
+ //preg_match_all("/table_prefix\s*=\s*'(\w*)';/", $content, $matches);
541
+ preg_match( "/table_prefix\s*=\s*'(\w*)';/", $content, $matches );
542
+ //wp_die(var_dump($matches));
543
+
544
+ if( !empty( $matches[1] ) ) {
545
+ return $matches[1];
546
+ } else {
547
+ return 'No table_prefix in wp-config.php';
548
+ }
549
+ }
550
+ }
551
+
552
+ /**
553
+ * Get staging site wordpress version number
554
+ * @return string
555
+ */
556
+ private function getStagingWpVersion( $path ) {
557
+
558
+ if( $path === 'undefined' ) {
559
+ return "Error: Cannot detect WP version";
560
+ }
561
+
562
+ // Get version number of wp staging
563
+ $file = $path . 'wp-includes/version.php';
564
+ $versionStaging = file_get_contents( $file );
565
+
566
+ preg_match( "/\\\$wp_version.*=.*'(.*)';/", $versionStaging, $matches );
567
+
568
+ $error = '';
569
+ if( empty( $matches[1] ) ) {
570
+ $error .= "Error: Cannot detect WP version";
571
+ }
572
+ return $matches[1];
573
+
574
+ }
575
 
576
  }
apps/Backend/Optimizer/Optimizer.php CHANGED
@@ -24,13 +24,17 @@ class Optimizer {
24
  }
25
 
26
  public function installOptimizer() {
 
 
 
 
27
  if( wp_mkdir_p( $this->mudir ) ) {
28
  $this->copy();
29
  }
30
  return false;
31
  }
32
 
33
- public function unstallOptimizer() {
34
  if( file_exists( $this->dest ) && !unlink( $this->dest ) ) {
35
  return false;
36
  }
@@ -42,4 +46,26 @@ class Optimizer {
42
  }
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
24
  }
25
 
26
  public function installOptimizer() {
27
+ if (file_exists( $this->dest ) && false === $this->mustUpdateOptimizer()){
28
+ return false;
29
+ }
30
+
31
  if( wp_mkdir_p( $this->mudir ) ) {
32
  $this->copy();
33
  }
34
  return false;
35
  }
36
 
37
+ public function uninstallOptimizer() {
38
  if( file_exists( $this->dest ) && !unlink( $this->dest ) ) {
39
  return false;
40
  }
46
  }
47
  }
48
 
49
+ /**
50
+ * Check if the Optimizer must use plugin must be updated
51
+ * @return boolean
52
+ */
53
+ private function mustUpdateOptimizer(){
54
+ $isVersionNumber = defined('WPSTG_OPTIMIZER_VERSION') ? WPSTG_OPTIMIZER_VERSION : false;
55
+
56
+ $update = false;
57
+
58
+ if (false === $isVersionNumber){
59
+ return true;
60
+ }
61
+
62
+ $mustVersionNumber = defined('WPSTG_OPTIMIZER_MUVERSION') ? WPSTG_OPTIMIZER_MUVERSION : false;
63
+
64
+ if ($mustVersionNumber){
65
+ $update = version_compare($isVersionNumber, $mustVersionNumber, '!=');
66
+ }
67
+
68
+ return $update;
69
+ }
70
+
71
  }
apps/Backend/Optimizer/wp-staging-optimizer.php CHANGED
@@ -10,6 +10,11 @@
10
  Credit: Original version is made by Delicious Brains (WP Migrate DB). Thank you guys!
11
  */
12
 
 
 
 
 
 
13
  /**
14
  * Get plugins dir
15
  * @return string
10
  Credit: Original version is made by Delicious Brains (WP Migrate DB). Thank you guys!
11
  */
12
 
13
+
14
+ if ( ! defined( 'WPSTG_OPTIMIZER_VERSION' ) ){
15
+ define( 'WPSTG_OPTIMIZER_VERSION', 1.1 );
16
+ }
17
+
18
  /**
19
  * Get plugins dir
20
  * @return string
apps/Core/WPStaging.php CHANGED
@@ -29,7 +29,7 @@ final class WPStaging {
29
  /**
30
  * Plugin version
31
  */
32
- const VERSION = "2.4.4";
33
 
34
  /**
35
  * Plugin name
29
  /**
30
  * Plugin version
31
  */
32
+ const VERSION = "2.4.6";
33
 
34
  /**
35
  * Plugin name
apps/Frontend/Frontend.php CHANGED
@@ -118,16 +118,16 @@ class Frontend extends InjectionAware {
118
  return false;
119
  }
120
 
121
- // Allow access for user role administrator in any case
122
- if( current_user_can( 'administrator' ) ) {
123
- //wp_die('is admin');
124
  return false;
125
  }
126
 
127
 
128
  return (
129
  (!isset( $this->settings->disableAdminLogin ) || '1' !== $this->settings->disableAdminLogin) &&
130
- (!current_user_can( "administrator" ) && !$this->isLoginPage() && !is_admin())
131
  );
132
  }
133
 
118
  return false;
119
  }
120
 
121
+ // Allow access for users with certain capabilitie only
122
+ if( current_user_can( 'manage_options' ) ) {
123
+ //if( current_user_can( 'administrator' ) ) {
124
  return false;
125
  }
126
 
127
 
128
  return (
129
  (!isset( $this->settings->disableAdminLogin ) || '1' !== $this->settings->disableAdminLogin) &&
130
+ (!current_user_can( "manage_options" ) && !$this->isLoginPage() && !is_admin())
131
  );
132
  }
133
 
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.0
12
- Stable tag: 2.4.4
13
  Requires PHP: 5.3
14
 
15
  A duplicator plugin! Clone, duplicate and migrate live sites to independent staging and development sites that are available only to administrators.
@@ -146,8 +146,15 @@ https://wp-staging.com
146
 
147
  == Changelog ==
148
 
 
 
 
149
  = 2.4.5 =
150
  * New: Compatible up to WordPress 5.0.1 Gutenberg
 
 
 
 
151
 
152
 
153
  = 2.4.4 =
@@ -201,8 +208,8 @@ Complete changelog: [https://wp-staging.com/wp-staging-changelog](https://wp-sta
201
 
202
  == Upgrade Notice ==
203
 
204
- = 2.4.4 =
205
  * Fix: Security, prevent downloading wp staging log files by third party users from uploads folder
206
- * New: Compatible up to WordPress 5.0 Gutenberg
207
 
208
 
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.0
12
+ Stable tag: 2.4.6
13
  Requires PHP: 5.3
14
 
15
  A duplicator plugin! Clone, duplicate and migrate live sites to independent staging and development sites that are available only to administrators.
146
 
147
  == Changelog ==
148
 
149
+ = 2.4.6 =
150
+ * Fix: Can not login to staging site . Changed minimum user capability to 'manage_options' instead 'administrator'
151
+
152
  = 2.4.5 =
153
  * New: Compatible up to WordPress 5.0.1 Gutenberg
154
+ * New: Show WP version of staging site in the sysinfo log
155
+ * Fix: Make sure optimizer must-use plugin is updated as well after updating the main plugin
156
+ * Fix: Plugin can not be uninstalled if WP Staging Pro is activated
157
+ * Fix: Prevent error $this not in object context in install.php
158
 
159
 
160
  = 2.4.4 =
208
 
209
  == Upgrade Notice ==
210
 
211
+ = 2.4.6 =
212
  * Fix: Security, prevent downloading wp staging log files by third party users from uploads folder
213
+ * New: Compatible up to WordPress 5.0.1 Gutenberg
214
 
215
 
uninstall.php CHANGED
@@ -14,7 +14,7 @@ use WPStaging\Backend\Optimizer\Optimizer;
14
  * @since 0.9.0
15
  */
16
  // No direct access
17
- if (!defined('WP_UNINSTALL_PLUGIN')) {
18
  exit;
19
  }
20
 
@@ -23,16 +23,16 @@ class uninstall {
23
  public function __construct() {
24
 
25
  // Plugin Folder Path
26
- if (!defined('WPSTG_PLUGIN_DIR')) {
27
- define('WPSTG_PLUGIN_DIR', plugin_dir_path(__FILE__));
28
  }
29
 
30
  /**
31
  * Path to main WP Staging class
32
  * Make sure to not redeclare class in case free version has been installed previosly
33
  */
34
- if (!class_exists('WPStaging\WPStaging')) {
35
- require_once plugin_dir_path(__FILE__) . "apps/Core/WPStaging.php";
36
  }
37
  $wpStaging = \WPStaging\WPStaging::getInstance();
38
 
@@ -44,18 +44,18 @@ class uninstall {
44
 
45
  private function init() {
46
 
47
- $options = json_decode(json_encode(get_option("wpstg_settings", array())));
48
 
49
- if (isset($options->unInstallOnDelete) && '1' === $options->unInstallOnDelete) {
50
  // Delete options
51
- delete_option("wpstg_version_upgraded_from");
52
- delete_option("wpstg_version");
53
- delete_option("wpstg_installDate");
54
- delete_option("wpstg_firsttime");
55
- delete_option("wpstg_is_staging_site");
56
- delete_option("wpstg_settings");
57
- delete_option("wpstg_rmpermalinks_executed");
58
- delete_option("wpstg_activation_redirect");
59
 
60
  /* Do not delete these fields without actually deleting the staging site
61
  * @create a delete routine which deletes the staging sites first
@@ -63,17 +63,17 @@ class uninstall {
63
  //delete_option( "wpstg_existing_clones" );
64
  //delete_option( "wpstg_existing_clones_beta" );
65
  // Old wpstg 1.3 options for admin notices
66
- delete_option("wpstg_start_poll");
67
- delete_option("wpstg_hide_beta");
68
- delete_option("wpstg_RatingDiv");
69
 
70
  // New 2.x options for admin notices
71
- delete_option("wpstg_poll");
72
- delete_option("wpstg_rating");
73
- delete_option("wpstg_beta");
74
 
75
  // Delete events
76
- wp_clear_scheduled_hook('wpstg_weekly_event');
77
  }
78
  }
79
 
@@ -81,8 +81,14 @@ class uninstall {
81
  * delete MuPlugin
82
  */
83
  private function deleteMuPlugin() {
84
- $optimizer = new Optimizer;
85
- $optimizer->unstallOptimizer();
 
 
 
 
 
 
86
  }
87
 
88
  }
14
  * @since 0.9.0
15
  */
16
  // No direct access
17
+ if( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
18
  exit;
19
  }
20
 
23
  public function __construct() {
24
 
25
  // Plugin Folder Path
26
+ if( !defined( 'WPSTG_PLUGIN_DIR' ) ) {
27
+ define( 'WPSTG_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
28
  }
29
 
30
  /**
31
  * Path to main WP Staging class
32
  * Make sure to not redeclare class in case free version has been installed previosly
33
  */
34
+ if( !class_exists( 'WPStaging\WPStaging' ) ) {
35
+ require_once plugin_dir_path( __FILE__ ) . "apps/Core/WPStaging.php";
36
  }
37
  $wpStaging = \WPStaging\WPStaging::getInstance();
38
 
44
 
45
  private function init() {
46
 
47
+ $options = json_decode( json_encode( get_option( "wpstg_settings", array() ) ) );
48
 
49
+ if( isset( $options->unInstallOnDelete ) && '1' === $options->unInstallOnDelete ) {
50
  // Delete options
51
+ delete_option( "wpstg_version_upgraded_from" );
52
+ delete_option( "wpstg_version" );
53
+ delete_option( "wpstg_installDate" );
54
+ delete_option( "wpstg_firsttime" );
55
+ delete_option( "wpstg_is_staging_site" );
56
+ delete_option( "wpstg_settings" );
57
+ delete_option( "wpstg_rmpermalinks_executed" );
58
+ delete_option( "wpstg_activation_redirect" );
59
 
60
  /* Do not delete these fields without actually deleting the staging site
61
  * @create a delete routine which deletes the staging sites first
63
  //delete_option( "wpstg_existing_clones" );
64
  //delete_option( "wpstg_existing_clones_beta" );
65
  // Old wpstg 1.3 options for admin notices
66
+ delete_option( "wpstg_start_poll" );
67
+ delete_option( "wpstg_hide_beta" );
68
+ delete_option( "wpstg_RatingDiv" );
69
 
70
  // New 2.x options for admin notices
71
+ delete_option( "wpstg_poll" );
72
+ delete_option( "wpstg_rating" );
73
+ delete_option( "wpstg_beta" );
74
 
75
  // Delete events
76
+ wp_clear_scheduled_hook( 'wpstg_weekly_event' );
77
  }
78
  }
79
 
81
  * delete MuPlugin
82
  */
83
  private function deleteMuPlugin() {
84
+ $muDir = ( defined( 'WPMU_PLUGIN_DIR' ) && defined( 'WPMU_PLUGIN_URL' ) ) ? WPMU_PLUGIN_DIR : trailingslashit( WP_CONTENT_DIR ) . 'mu-plugins';
85
+ $destination = trailingslashit( $muDir ) . 'wp-staging-optimizer.php';
86
+ if( file_exists( $destination ) && !unlink( $destination ) ) {
87
+ return false;
88
+ }
89
+
90
+ //$optimizer = new Optimizer;
91
+ //$optimizer->unstallOptimizer();
92
  }
93
 
94
  }
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.4.4
11
  * Text Domain: wp-staging
12
  * Domain Path: /languages/
13
 
@@ -51,7 +51,12 @@ if( !defined( 'WPSTG_PLUGIN_URL' ) ) {
51
 
52
  // Version
53
  if( !defined( 'WPSTG_VERSION' ) ) {
54
- define( 'WPSTG_VERSION', '2.4.4' );
 
 
 
 
 
55
  }
56
 
57
  /**
7
  * Author: WP-Staging
8
  * Author URI: https://wp-staging.com
9
  * Contributors: ReneHermi, ilgityildirim
10
+ * Version: 2.4.6
11
  * Text Domain: wp-staging
12
  * Domain Path: /languages/
13
 
51
 
52
  // Version
53
  if( !defined( 'WPSTG_VERSION' ) ) {
54
+ define( 'WPSTG_VERSION', '2.4.6' );
55
+ }
56
+
57
+ // Must use version of the optimizer
58
+ if( !defined( 'WPSTG_OPTIMIZER_MUVERSION' ) ) {
59
+ define( 'WPSTG_OPTIMIZER_MUVERSION', 1.1 );
60
  }
61
 
62
  /**