Migration, Backup, Staging – WPvivid - Version 0.9.62

Version Description

  • Added a check to the permissions of the staging folder before creating a staging site.
  • Fixed some bugs in the plugin code.
  • Optimized the plugin code.
  • Successfully tested with WordPress 5.8.1.
Download this release

Release Info

Developer wpvivid
Plugin Icon 128x128 Migration, Backup, Staging – WPvivid
Version 0.9.62
Comparing to
See all releases

Code changes from version 0.9.61 to 0.9.62

admin/class-wpvivid-admin.php CHANGED
@@ -283,6 +283,14 @@ class WPvivid_Admin {
283
 
284
  function add_toolbar_items($wp_admin_bar)
285
  {
 
 
 
 
 
 
 
 
286
  global $wpvivid_plugin;
287
  if(is_admin())
288
  {
283
 
284
  function add_toolbar_items($wp_admin_bar)
285
  {
286
+ if (is_multisite())
287
+ {
288
+ if(!is_network_admin())
289
+ {
290
+ return ;
291
+ }
292
+ }
293
+
294
  global $wpvivid_plugin;
295
  if(is_admin())
296
  {
includes/staging/class-wpvivid-fresh-install-create-ui-display.php CHANGED
@@ -519,75 +519,95 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
519
  return;
520
  }
521
 
522
- var additional_database_json = {};
523
-
524
- var additional_database_option = '0';
525
- jQuery('input[option=create_wp][name=choose_create_staging_db]').each(function ()
526
- {
527
- if (jQuery(this).prop('checked'))
528
  {
529
- additional_database_option = jQuery(this).val();
530
- }
531
- });
532
-
533
- if (additional_database_option === '1')
534
  {
535
- additional_database_json['additional_database_check'] = '1';
536
- additional_database_json['additional_database_info'] = {};
537
- additional_database_json['additional_database_info']['db_user'] = jQuery('input[option=create_wp][name=database-user]').val();
538
- additional_database_json['additional_database_info']['db_pass'] = jQuery('input[option=create_wp][name=database-pass]').val();
539
- additional_database_json['additional_database_info']['db_host'] = jQuery('input[option=create_wp][name=database-host]').val();
540
- additional_database_json['additional_database_info']['db_name'] = jQuery('input[option=create_wp][name=database-name]').val();
541
- if (additional_database_json['additional_database_info']['db_name'] === '')
542
- {
543
- alert('Database Name is required.');
544
- return;
545
- }
546
- if (additional_database_json['additional_database_info']['db_user'] === '')
547
  {
548
- alert('Database User is required.');
549
- return;
550
  }
551
- if (additional_database_json['additional_database_info']['db_host'] === '')
552
  {
553
- alert('Database Host is required.');
554
- return;
555
- }
556
- }
557
- else {
558
- additional_database_json['additional_database_check'] = '0';
559
- }
560
- var additional_database_info=JSON.stringify(additional_database_json);
561
- var custom_dir_json = wpvivid_get_custom_create_new_wp_option();
562
- var custom_dir = JSON.stringify(custom_dir_json);
563
 
564
- var ajax_data = {
565
- 'action': 'wpvividstg_start_staging_free',
566
- 'create_new_wp':true,
567
- 'path': path,
568
- 'table_prefix': table_prefix,
569
- 'custom_dir': custom_dir,
570
- 'additional_db': additional_database_info,
571
- 'root_dir':staging_root_dir,
572
- };
573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
 
575
- jQuery('#wpvivid_create_new_wp_content').hide();
576
- jQuery('#wpvivid_create_new_wp_progress').show();
 
 
 
 
 
 
 
577
 
578
- wpvivid_post_request(ajax_data, function (data)
579
- {
580
- setTimeout(function ()
581
- {
582
- wpvivid_get_create_new_wp_progress();
583
- }, staging_requet_timeout);
584
- }, function (XMLHttpRequest, textStatus, errorThrown)
585
- {
586
- jQuery('#wpvivid_create_new_wp_content').hide();
587
- jQuery('#wpvivid_create_new_wp_progress').show();
588
- setTimeout(function () {
589
- wpvivid_get_create_new_wp_progress();
590
- }, staging_requet_timeout);
 
 
 
 
 
 
 
 
 
591
  });
592
  }
593
 
519
  return;
520
  }
521
 
522
+ var ajax_data =
 
 
 
 
 
523
  {
524
+ 'action': 'wpvividstg_check_filesystem_permissions_free',
525
+ 'root_dir':staging_root_dir,
526
+ 'path': path
527
+ };
528
+ wpvivid_post_request(ajax_data, function (data)
529
  {
530
+ var jsonarray = jQuery.parseJSON(data);
531
+ if (jsonarray.result === 'failed')
 
 
 
 
 
 
 
 
 
 
532
  {
533
+ alert(jsonarray.error);
 
534
  }
535
+ else
536
  {
537
+ var additional_database_json = {};
 
 
 
 
 
 
 
 
 
538
 
539
+ var additional_database_option = '0';
540
+ jQuery('input[option=create_wp][name=choose_create_staging_db]').each(function ()
541
+ {
542
+ if (jQuery(this).prop('checked'))
543
+ {
544
+ additional_database_option = jQuery(this).val();
545
+ }
546
+ });
 
547
 
548
+ if (additional_database_option === '1')
549
+ {
550
+ additional_database_json['additional_database_check'] = '1';
551
+ additional_database_json['additional_database_info'] = {};
552
+ additional_database_json['additional_database_info']['db_user'] = jQuery('input[option=create_wp][name=database-user]').val();
553
+ additional_database_json['additional_database_info']['db_pass'] = jQuery('input[option=create_wp][name=database-pass]').val();
554
+ additional_database_json['additional_database_info']['db_host'] = jQuery('input[option=create_wp][name=database-host]').val();
555
+ additional_database_json['additional_database_info']['db_name'] = jQuery('input[option=create_wp][name=database-name]').val();
556
+ if (additional_database_json['additional_database_info']['db_name'] === '')
557
+ {
558
+ alert('Database Name is required.');
559
+ return;
560
+ }
561
+ if (additional_database_json['additional_database_info']['db_user'] === '')
562
+ {
563
+ alert('Database User is required.');
564
+ return;
565
+ }
566
+ if (additional_database_json['additional_database_info']['db_host'] === '')
567
+ {
568
+ alert('Database Host is required.');
569
+ return;
570
+ }
571
+ }
572
+ else {
573
+ additional_database_json['additional_database_check'] = '0';
574
+ }
575
+ var additional_database_info=JSON.stringify(additional_database_json);
576
+ var custom_dir_json = wpvivid_get_custom_create_new_wp_option();
577
+ var custom_dir = JSON.stringify(custom_dir_json);
578
 
579
+ var ajax_data = {
580
+ 'action': 'wpvividstg_start_staging_free',
581
+ 'create_new_wp':true,
582
+ 'path': path,
583
+ 'table_prefix': table_prefix,
584
+ 'custom_dir': custom_dir,
585
+ 'additional_db': additional_database_info,
586
+ 'root_dir':staging_root_dir,
587
+ };
588
 
589
+
590
+ jQuery('#wpvivid_create_new_wp_content').hide();
591
+ jQuery('#wpvivid_create_new_wp_progress').show();
592
+
593
+ wpvivid_post_request(ajax_data, function (data)
594
+ {
595
+ setTimeout(function ()
596
+ {
597
+ wpvivid_get_create_new_wp_progress();
598
+ }, staging_requet_timeout);
599
+ }, function (XMLHttpRequest, textStatus, errorThrown)
600
+ {
601
+ jQuery('#wpvivid_create_new_wp_content').hide();
602
+ jQuery('#wpvivid_create_new_wp_progress').show();
603
+ setTimeout(function () {
604
+ wpvivid_get_create_new_wp_progress();
605
+ }, staging_requet_timeout);
606
+ });
607
+ }
608
+ }, function (XMLHttpRequest, textStatus, errorThrown) {
609
+ var error_message = wpvivid_output_ajaxerror('creating staging site', textStatus, errorThrown);
610
+ alert(error_message);
611
  });
612
  }
613
 
includes/staging/class-wpvivid-staging-create-ui-display.php CHANGED
@@ -619,40 +619,60 @@ class WPvivid_Staging_Create_UI_Display_Free
619
  }
620
  else
621
  {
622
- jQuery('#wpvivid_staging_log').html("");
623
- jQuery('#wpvivid_staging_progress_bar').css('width', '0%');
624
- jQuery('#wpvivid_staging_progress_bar').find('div').eq(0).html('0%');
625
- var custom_dir_json = wpvivid_create_custom_json('wpvivid_custom_staging_list');
626
- var custom_dir = JSON.stringify(custom_dir_json);
627
- var check_select = true;
628
-
629
- wpvivid_create_staging_lock_unlock('lock');
630
-
631
- var ajax_data = {
632
- 'action': 'wpvividstg_start_staging_free',
633
- 'path': path,
634
- 'table_prefix': table_prefix,
635
- 'custom_dir': custom_dir,
636
- 'additional_db': additional_database_info,
637
- 'root_dir':staging_root_dir
638
- };
639
-
640
- jQuery('#wpvivid_choose_staging_content').hide();
641
- jQuery('#wpvivid_create_btn').hide();
642
- jQuery('#wpvivid_create_staging_step2').show();
643
  wpvivid_post_request(ajax_data, function (data)
644
  {
645
- setTimeout(function () {
646
- wpvivid_get_staging_progress();
647
- }, staging_requet_timeout);
648
- }, function (XMLHttpRequest, textStatus, errorThrown)
649
- {
650
- jQuery('#wpvivid_choose_staging_content').hide();
651
- jQuery('#wpvivid_create_btn').hide();
652
- jQuery('#wpvivid_create_staging_step2').show();
653
- setTimeout(function () {
654
- wpvivid_get_staging_progress();
655
- }, staging_requet_timeout);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
  });
657
  }
658
  }, function (XMLHttpRequest, textStatus, errorThrown) {
619
  }
620
  else
621
  {
622
+ var ajax_data =
623
+ {
624
+ 'action': 'wpvividstg_check_filesystem_permissions_free',
625
+ 'root_dir':staging_root_dir,
626
+ 'path': path
627
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  wpvivid_post_request(ajax_data, function (data)
629
  {
630
+ var jsonarray = jQuery.parseJSON(data);
631
+ if (jsonarray.result === 'failed')
632
+ {
633
+ alert(jsonarray.error);
634
+ }
635
+ else
636
+ {
637
+ jQuery('#wpvivid_staging_log').html("");
638
+ jQuery('#wpvivid_staging_progress_bar').css('width', '0%');
639
+ jQuery('#wpvivid_staging_progress_bar').find('div').eq(0).html('0%');
640
+ var custom_dir_json = wpvivid_create_custom_json('wpvivid_custom_staging_list');
641
+ var custom_dir = JSON.stringify(custom_dir_json);
642
+ var check_select = true;
643
+
644
+ wpvivid_create_staging_lock_unlock('lock');
645
+
646
+ var ajax_data = {
647
+ 'action': 'wpvividstg_start_staging_free',
648
+ 'path': path,
649
+ 'table_prefix': table_prefix,
650
+ 'custom_dir': custom_dir,
651
+ 'additional_db': additional_database_info,
652
+ 'root_dir':staging_root_dir
653
+ };
654
+
655
+ jQuery('#wpvivid_choose_staging_content').hide();
656
+ jQuery('#wpvivid_create_btn').hide();
657
+ jQuery('#wpvivid_create_staging_step2').show();
658
+ wpvivid_post_request(ajax_data, function (data)
659
+ {
660
+ setTimeout(function () {
661
+ wpvivid_get_staging_progress();
662
+ }, staging_requet_timeout);
663
+ }, function (XMLHttpRequest, textStatus, errorThrown)
664
+ {
665
+ jQuery('#wpvivid_choose_staging_content').hide();
666
+ jQuery('#wpvivid_create_btn').hide();
667
+ jQuery('#wpvivid_create_staging_step2').show();
668
+ setTimeout(function () {
669
+ wpvivid_get_staging_progress();
670
+ }, staging_requet_timeout);
671
+ });
672
+ }
673
+ }, function (XMLHttpRequest, textStatus, errorThrown) {
674
+ var error_message = wpvivid_output_ajaxerror('creating staging site', textStatus, errorThrown);
675
+ alert(error_message);
676
  });
677
  }
678
  }, function (XMLHttpRequest, textStatus, errorThrown) {
includes/staging/class-wpvivid-staging.php CHANGED
@@ -166,6 +166,7 @@ class WPvivid_Staging_Free
166
  add_action('wp_ajax_wpvividstg_delete_site_free', array($this, 'delete_site'));
167
  add_action('wp_ajax_wpvividstg_delete_cancel_staging_site_free', array($this, 'delete_cancel_staging_site'));
168
  add_action('wp_ajax_wpvividstg_check_staging_dir_free', array($this, 'check_staging_dir'));
 
169
  //
170
  add_action('wp_ajax_wpvividstg_get_custom_database_tables_info_free',array($this, 'get_custom_database_tables_info'));
171
 
@@ -1777,6 +1778,75 @@ class WPvivid_Staging_Free
1777
  die();
1778
  }
1779
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1780
  public function get_recent_post()
1781
  {
1782
  //set_prefix
166
  add_action('wp_ajax_wpvividstg_delete_site_free', array($this, 'delete_site'));
167
  add_action('wp_ajax_wpvividstg_delete_cancel_staging_site_free', array($this, 'delete_cancel_staging_site'));
168
  add_action('wp_ajax_wpvividstg_check_staging_dir_free', array($this, 'check_staging_dir'));
169
+ add_action('wp_ajax_wpvividstg_check_filesystem_permissions_free', array($this, 'check_filesystem_permissions'));
170
  //
171
  add_action('wp_ajax_wpvividstg_get_custom_database_tables_info_free',array($this, 'get_custom_database_tables_info'));
172
 
1778
  die();
1779
  }
1780
 
1781
+ public function check_filesystem_permissions()
1782
+ {
1783
+ global $wpvivid_plugin;
1784
+ $wpvivid_plugin->ajax_check_security();
1785
+ try{
1786
+ if(!isset($_POST['path']) || empty($_POST['path']) || !is_string($_POST['path']))
1787
+ {
1788
+ $ret['result']='failed';
1789
+ $ret['error']='A site path is required.';
1790
+ echo json_encode($ret);
1791
+ die();
1792
+ }
1793
+
1794
+ $path = sanitize_text_field($_POST['path']);
1795
+ $src_path = untrailingslashit(ABSPATH);
1796
+
1797
+ if(isset($_POST['root_dir'])&&$_POST['root_dir']==0)
1798
+ {
1799
+ $des_path = untrailingslashit(ABSPATH) . '/' . $path;
1800
+ }
1801
+ else if (isset($_POST['root_dir'])&&$_POST['root_dir']==1)
1802
+ {
1803
+ $des_path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $path;
1804
+ }
1805
+ else
1806
+ {
1807
+ $test_dir = 'wpvividstg_testfolder';
1808
+ $des_path = untrailingslashit($path) . '/' . $test_dir;
1809
+ }
1810
+
1811
+ $mk_res = mkdir($des_path,0755,true);
1812
+ if (!$mk_res)
1813
+ {
1814
+ $ret['result']='failed';
1815
+ $ret['error']='The directory where the staging site will be installed is not writable. Please set the permissions of the directory to 755 then try it again.';
1816
+ echo json_encode($ret);
1817
+ die();
1818
+ }
1819
+
1820
+ $test_file_name = 'wpvividstg_test_file.txt';
1821
+ $test_file_path = $des_path.DIRECTORY_SEPARATOR.$test_file_name;
1822
+ $mk_res = fopen($test_file_path, 'wb');
1823
+ if (!$mk_res)
1824
+ {
1825
+ if(file_exists($des_path))
1826
+ @rmdir($des_path);
1827
+ $ret['result']='failed';
1828
+ $ret['error']='The directory where the staging site will be installed is not writable. Please set the permissions of the directory to 755 then try it again.';
1829
+ echo json_encode($ret);
1830
+ die();
1831
+ }
1832
+
1833
+ fclose($mk_res);
1834
+ @unlink($test_file_path);
1835
+ if(file_exists($des_path))
1836
+ @rmdir($des_path);
1837
+
1838
+ $ret['result'] = 'success';
1839
+ echo json_encode($ret);
1840
+ }
1841
+ catch (Exception $error)
1842
+ {
1843
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
1844
+ error_log($message);
1845
+ echo json_encode(array('result'=>'failed','error'=>$message));
1846
+ }
1847
+ die();
1848
+ }
1849
+
1850
  public function get_recent_post()
1851
  {
1852
  //set_prefix
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
- Tested up to: 5.8
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.61
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -192,6 +192,11 @@ Thank you for translating WPvivid Backup Plugin to your languages!
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
 
 
 
 
 
195
  = 0.9.61 =
196
  - Added support for migration of unconventional save of the media paths.
197
  - Fixed some bugs in the plugin code.
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
+ Tested up to: 5.8.1
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.62
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
195
+ = 0.9.62 =
196
+ - Added a check to the permissions of the staging folder before creating a staging site.
197
+ - Fixed some bugs in the plugin code.
198
+ - Optimized the plugin code.
199
+ - Successfully tested with WordPress 5.8.1.
200
  = 0.9.61 =
201
  - Added support for migration of unconventional save of the media paths.
202
  - Fixed some bugs in the plugin code.
wpvivid-backuprestore.php CHANGED
@@ -7,7 +7,7 @@
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
- * Version: 0.9.61
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
@@ -21,7 +21,7 @@ if ( ! defined( 'WPINC' ) ) {
21
  die;
22
  }
23
 
24
- define( 'WPVIVID_PLUGIN_VERSION', '0.9.61' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
+ * Version: 0.9.62
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
21
  die;
22
  }
23
 
24
+ define( 'WPVIVID_PLUGIN_VERSION', '0.9.62' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');