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

Version Description

  • Fix: Activation hook is not fired and staging site is not working properly
  • Performance: Increase default query copy limit to 1000
Download this release

Release Info

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

Code changes from version 1.0.6 to 1.0.7

includes/admin/settings/register-settings.php CHANGED
@@ -134,7 +134,7 @@ function wpstg_get_registered_settings() {
134
  'desc' => __('Number of DB rows, that will be copied within one ajax request. The higher the value the faster the database copy process. To find out the highest possible values try a high value like 1.000 or more and decrease it until you get no more errors during copy process. <strong> Default: 100 </strong>'),
135
  'type' => 'number',
136
  'size' => 'medium',
137
- 'std' => 100,
138
  ),
139
  array(
140
  'id' => 'wpstg_batch_size',
134
  'desc' => __('Number of DB rows, that will be copied within one ajax request. The higher the value the faster the database copy process. To find out the highest possible values try a high value like 1.000 or more and decrease it until you get no more errors during copy process. <strong> Default: 100 </strong>'),
135
  'type' => 'number',
136
  'size' => 'medium',
137
+ 'std' => 1000,
138
  ),
139
  array(
140
  'id' => 'wpstg_batch_size',
includes/install.php CHANGED
@@ -18,11 +18,11 @@ if ( ! defined( 'ABSPATH' ) ) exit;
18
  *
19
  */
20
 
21
- register_activation_hook( WPSTG_PLUGIN_FILE, 'wpstg_install_multisite' );
22
-
23
- function wpstg_install_multisite($networkwide) {
24
  global $wpdb;
25
-
 
26
  if (function_exists('is_multisite') && is_multisite()) {
27
  // check if it is a network activation - if so, run the activation function for each blog id
28
  if ($networkwide) {
@@ -38,7 +38,7 @@ function wpstg_install_multisite($networkwide) {
38
  }
39
  }
40
  wpstg_install();
41
- }
42
 
43
  /**
44
  * Install
@@ -58,7 +58,6 @@ function wpstg_install_multisite($networkwide) {
58
 
59
  function wpstg_install() {
60
  global $wpdb, $wpstg_options, $wp_version;
61
-
62
 
63
  // Add Upgraded from Option
64
  $current_version = get_option( 'wpstg_version' );
@@ -128,6 +127,17 @@ function wpstg_after_install() {
128
  }
129
  add_action( 'admin_init', 'wpstg_after_install' );
130
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
  /**
133
  * Create json remaining_files.json after activation of the plugin
@@ -135,7 +145,7 @@ add_action( 'admin_init', 'wpstg_after_install' );
135
  * @return bool
136
  */
137
  function wpstg_create_remaining_files() {
138
- $path = wpstg_get_upload_dir();
139
  if (wp_is_writable($path)) {
140
  $file = 'remaining_files.json';
141
  file_put_contents($path . '/' . $file, null);
@@ -150,7 +160,7 @@ function wpstg_create_remaining_files() {
150
  * @return bool
151
  */
152
  function wpstg_create_clonedetails_files() {
153
- $path = wpstg_get_upload_dir();
154
  if (wp_is_writable($path)) {
155
  $file = 'clone_details.json';
156
  file_put_contents($path . '/' . $file, null);
18
  *
19
  */
20
 
21
+ //register_activation_hook( WPSTG_PLUGIN_FILE, 'wpstg_install_multisite' );
22
+ /*function wpstg_install_multisite($networkwide) {
 
23
  global $wpdb;
24
+ wp_die('fire');
25
+
26
  if (function_exists('is_multisite') && is_multisite()) {
27
  // check if it is a network activation - if so, run the activation function for each blog id
28
  if ($networkwide) {
38
  }
39
  }
40
  wpstg_install();
41
+ }*/
42
 
43
  /**
44
  * Install
58
 
59
  function wpstg_install() {
60
  global $wpdb, $wpstg_options, $wp_version;
 
61
 
62
  // Add Upgraded from Option
63
  $current_version = get_option( 'wpstg_version' );
127
  }
128
  add_action( 'admin_init', 'wpstg_after_install' );
129
 
130
+ /**
131
+ * Get upload dir
132
+ *
133
+ * @return string
134
+ */
135
+ function wpstg_install_get_upload_dir() {
136
+ $wp_upload_dir = wp_upload_dir();
137
+ wp_mkdir_p( $wp_upload_dir['basedir'] . '/wp-staging' );
138
+ $path = $wp_upload_dir['basedir'] . '/wp-staging';
139
+ return $path;
140
+ }
141
 
142
  /**
143
  * Create json remaining_files.json after activation of the plugin
145
  * @return bool
146
  */
147
  function wpstg_create_remaining_files() {
148
+ $path = wpstg_install_get_upload_dir();
149
  if (wp_is_writable($path)) {
150
  $file = 'remaining_files.json';
151
  file_put_contents($path . '/' . $file, null);
160
  * @return bool
161
  */
162
  function wpstg_create_clonedetails_files() {
163
+ $path = wpstg_install_get_upload_dir();
164
  if (wp_is_writable($path)) {
165
  $file = 'clone_details.json';
166
  file_put_contents($path . '/' . $file, null);
includes/template-functions.php CHANGED
@@ -633,7 +633,7 @@ function wpstg_clone_db_internal() {
633
  wpstg_return_json('wpstg_clone_db_internal', 'success', 'DB successfull copied', 1, wpstg_get_runtime());
634
 
635
 
636
- $limit = isset($wpstg_options['wpstg_query_limit']) ? $wpstg_options['wpstg_query_limit'] : 100;
637
  $rows_count = 0;
638
  $log_data = '';
639
 
@@ -1055,7 +1055,7 @@ function wpstg_replace_links() {
1055
  //wp_die(-1);
1056
  //wp_die('Updating option[wpstg_is_staging_site] has been failed');
1057
  wpstg_save_options();
1058
- wpstg_return_json('wpstg_replace_links', 'fail', '[' . date('d-m-Y H:i:s') . '] <span style="color:red;">Fail: </span> Updating db' . $new_prefix . 'options where option_name = wpstg_is_staging_site has been failed', $wpstg_clone_details['links_progress'], wpstg_get_runtime());
1059
  } else {
1060
  $wpstg_clone_details['links_progress'] = 0.43;
1061
  wpstg_log('Updating option [wpstg_is_staging_site] has been done succesfully');
633
  wpstg_return_json('wpstg_clone_db_internal', 'success', 'DB successfull copied', 1, wpstg_get_runtime());
634
 
635
 
636
+ $limit = isset($wpstg_options['wpstg_query_limit']) ? $wpstg_options['wpstg_query_limit'] : 1000;
637
  $rows_count = 0;
638
  $log_data = '';
639
 
1055
  //wp_die(-1);
1056
  //wp_die('Updating option[wpstg_is_staging_site] has been failed');
1057
  wpstg_save_options();
1058
+ wpstg_return_json('wpstg_replace_links', 'fail', '[' . date('d-m-Y H:i:s') . '] <span style="color:red;">Fail: </span> Updating db ' . $new_prefix . 'options where option_name = wpstg_is_staging_site has been failed', $wpstg_clone_details['links_progress'], wpstg_get_runtime());
1059
  } else {
1060
  $wpstg_clone_details['links_progress'] = 0.43;
1061
  wpstg_log('Updating option [wpstg_is_staging_site] has been done succesfully');
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: 4.5
12
- Stable tag: 1.0.6
13
 
14
  A duplicator plugin! Clone, duplicate and migrate live sites to independent staging and development sites that are available only to administrators.
15
 
@@ -141,6 +141,10 @@ After installation goto the settings page 'Staging' and do your adjustments ther
141
 
142
  == Changelog ==
143
 
 
 
 
 
144
  = 1.0.6 =
145
  * Fix: Uninstalling plugin throwing error
146
  * Fix: Error permission admin notice although permission issues are correct
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: 4.5
12
+ Stable tag: 1.0.7
13
 
14
  A duplicator plugin! Clone, duplicate and migrate live sites to independent staging and development sites that are available only to administrators.
15
 
141
 
142
  == Changelog ==
143
 
144
+ = 1.0.7 =
145
+ * Fix: Activation hook is not fired and staging site is not working properly
146
+ * Performance: Increase default query copy limit to 1000
147
+
148
  = 1.0.6 =
149
  * Fix: Uninstalling plugin throwing error
150
  * Fix: Error permission admin notice although permission issues are correct
wp-staging.php CHANGED
@@ -6,7 +6,7 @@
6
  * Description: Create a staging clone site for testing & developing
7
  * Author: WP-Staging, René Hermenau
8
  * Author URI: https://wordpress.org/plugins/wp-staging
9
- * Version: 1.0.6
10
  * Text Domain: wpstg
11
  * Domain Path: languages
12
 
@@ -29,32 +29,60 @@
29
  * @author René Hermenau
30
  */
31
  // Exit if accessed directly
32
- if ( !defined('ABSPATH') )
33
  exit;
34
 
35
  // Plugin version
36
- if ( !defined('WPSTG_VERSION') ) {
37
- define('WPSTG_VERSION', '1.0.6');
38
  }
39
  // Is compatible up to WordPress version
40
- if ( !defined('WPSTG_WP_COMPATIBLE') ) {
41
- define('WPSTG_WP_COMPATIBLE', '4.5.1');
42
  }
43
 
44
  // Plugin Folder Path
45
- if ( !defined('WPSTG_PLUGIN_DIR') ) {
46
- define('WPSTG_PLUGIN_DIR', plugin_dir_path(__FILE__));
 
 
 
 
 
47
  }
48
 
49
  // Files that needs to be loaded early
50
- if ( !class_exists('WPSTG_Utils') ) {
51
- require dirname(__FILE__) . '/includes/wpstg-utils.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
 
54
  /*
55
  * Main class wpstaging
56
  */
57
- if ( !class_exists('wpstaging') ) :
58
 
59
  /**
60
  * Main wpstg Class
@@ -75,7 +103,6 @@ if ( !class_exists('wpstaging') ) :
75
  self::load_textdomain();
76
  }
77
 
78
-
79
  /**
80
  * Setup plugin constants
81
  *
@@ -85,28 +112,22 @@ if ( !class_exists('wpstaging') ) :
85
  */
86
  private function setup_constants() {
87
  //global $wpdb;
88
-
89
  // Plugin Folder Path
90
- if ( !defined('WPSTG_PLUGIN_DIR') ) {
91
- define('WPSTG_PLUGIN_DIR', plugin_dir_path(__FILE__));
92
  }
93
 
94
  // Plugin Folder URL
95
- if ( !defined('WPSTG_PLUGIN_URL') ) {
96
- define('WPSTG_PLUGIN_URL', plugin_dir_url(__FILE__));
97
  }
98
 
99
- // Plugin Root File
100
- if ( !defined('WPSTG_PLUGIN_FILE') ) {
101
- define('WPSTG_PLUGIN_FILE', __FILE__);
102
  }
103
 
104
- if ( !defined('WPSTG_NAME') ) {
105
- define('WPSTG_NAME', 'WP Staging');
106
- }
107
-
108
- if ( !defined('WPSTG_SLUG') ) {
109
- define('WPSTG_SLUG', 'wp-staging');
110
  }
111
  }
112
 
@@ -122,9 +143,10 @@ if ( !class_exists('wpstaging') ) :
122
  require_once WPSTG_PLUGIN_DIR . 'includes/logger.php';
123
  require_once WPSTG_PLUGIN_DIR . 'includes/scripts.php';
124
  require_once WPSTG_PLUGIN_DIR . 'includes/staging-functions.php';
125
- if ( is_admin() || ( defined('WP_CLI') && WP_CLI ) ) {
126
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/settings/register-settings.php';
127
  $wpstg_options = wpstg_get_settings(); // Load it on top of all
 
128
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/admin-actions.php';
129
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/admin-notices.php';
130
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/admin-footer.php';
@@ -133,7 +155,6 @@ if ( !class_exists('wpstaging') ) :
133
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/welcome.php';
134
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/settings/display-settings.php';
135
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/settings/contextual-help.php';
136
- require_once WPSTG_PLUGIN_DIR . 'includes/install.php';
137
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/tools.php';
138
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/upload-functions.php';
139
  require_once WPSTG_PLUGIN_DIR . 'includes/class-wpstg-license-handler.php';
@@ -145,6 +166,26 @@ if ( !class_exists('wpstaging') ) :
145
  }
146
  }
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  /**
149
  * Loads the plugin language files
150
  *
@@ -154,26 +195,26 @@ if ( !class_exists('wpstaging') ) :
154
  */
155
  public function load_textdomain() {
156
  // Set filter for plugin's languages directory
157
- $wpstg_lang_dir = dirname(plugin_basename(WPSTG_PLUGIN_FILE)) . '/languages/';
158
- $wpstg_lang_dir = apply_filters('wpstg_languages_directory', $wpstg_lang_dir);
159
 
160
  // Traditional WordPress plugin locale filter
161
- $locale = apply_filters('plugin_locale', get_locale(), 'wpstg');
162
- $mofile = sprintf('%1$s-%2$s.mo', 'wpstg', $locale);
163
 
164
  // Setup paths to current locale file
165
  $mofile_local = $wpstg_lang_dir . $mofile;
166
  $mofile_global = WP_LANG_DIR . '/wpstg/' . $mofile;
167
 
168
- if ( file_exists($mofile_global) ) {
169
  // Look in global /wp-content/languages/WPSTG folder
170
- load_textdomain('wpstg', $mofile_global);
171
- } elseif ( file_exists($mofile_local) ) {
172
  // Look in local /wp-content/plugins/wp-staging/languages/ folder
173
- load_textdomain('wpstg', $mofile_local);
174
  } else {
175
  // Load the default language files
176
- load_plugin_textdomain('wpstg', false, $wpstg_lang_dir);
177
  }
178
  }
179
 
@@ -190,7 +231,7 @@ function wp_staging_loaded() {
190
 
191
  global $wpstg;
192
 
193
- if ( !is_null($wpstg) ) {
194
  return $wpstg;
195
  }
196
 
@@ -199,7 +240,7 @@ function wp_staging_loaded() {
199
  //WPSTG();
200
  }
201
 
202
- add_action('plugins_loaded', 'wp_staging_loaded');
203
 
204
  /* function WPSTG() {
205
  global $wpstg;
@@ -213,4 +254,4 @@ add_action('plugins_loaded', 'wp_staging_loaded');
213
  } */
214
 
215
  // Deactivate WPSTG (Pro)
216
- add_action('activated_plugin', array('WPSTG_Utils', 'deactivate_other_instances'));
6
  * Description: Create a staging clone site for testing & developing
7
  * Author: WP-Staging, René Hermenau
8
  * Author URI: https://wordpress.org/plugins/wp-staging
9
+ * Version: 1.0.7
10
  * Text Domain: wpstg
11
  * Domain Path: languages
12
 
29
  * @author René Hermenau
30
  */
31
  // Exit if accessed directly
32
+ if( !defined( 'ABSPATH' ) )
33
  exit;
34
 
35
  // Plugin version
36
+ if( !defined( 'WPSTG_VERSION' ) ) {
37
+ define( 'WPSTG_VERSION', '1.0.7' );
38
  }
39
  // Is compatible up to WordPress version
40
+ if( !defined( 'WPSTG_WP_COMPATIBLE' ) ) {
41
+ define( 'WPSTG_WP_COMPATIBLE', '4.5.1' );
42
  }
43
 
44
  // Plugin Folder Path
45
+ if( !defined( 'WPSTG_PLUGIN_DIR' ) ) {
46
+ define( 'WPSTG_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
47
+ }
48
+
49
+ // Plugin Root File
50
+ if( !defined( 'WPSTG_PLUGIN_FILE' ) ) {
51
+ define( 'WPSTG_PLUGIN_FILE', __FILE__ );
52
  }
53
 
54
  // Files that needs to be loaded early
55
+ if( !class_exists( 'WPSTG_Utils' ) ) {
56
+ require dirname( __FILE__ ) . '/includes/wpstg-utils.php';
57
+ }
58
+
59
+ // Installation & activation
60
+ register_activation_hook( __FILE__, 'wpstg_activation' );
61
+ function wpstg_activation($networkwide){
62
+ require_once WPSTG_PLUGIN_DIR . '/includes/install.php';
63
+
64
+ if (function_exists('is_multisite') && is_multisite()) {
65
+ // check if it is a network activation - if so, run the activation function for each blog id
66
+ if ($networkwide) {
67
+ $old_blog = $wpdb->blogid;
68
+ // Get all blog ids
69
+ $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
70
+ foreach ($blogids as $blog_id) {
71
+ switch_to_blog($blog_id);
72
+ wpstg_install();
73
+ }
74
+ switch_to_blog($old_blog);
75
+ return;
76
+ }
77
+ }
78
+
79
+ wpstg_install();
80
  }
81
 
82
  /*
83
  * Main class wpstaging
84
  */
85
+ if( !class_exists( 'wpstaging' ) ) :
86
 
87
  /**
88
  * Main wpstg Class
103
  self::load_textdomain();
104
  }
105
 
 
106
  /**
107
  * Setup plugin constants
108
  *
112
  */
113
  private function setup_constants() {
114
  //global $wpdb;
 
115
  // Plugin Folder Path
116
+ if( !defined( 'WPSTG_PLUGIN_DIR' ) ) {
117
+ define( 'WPSTG_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
118
  }
119
 
120
  // Plugin Folder URL
121
+ if( !defined( 'WPSTG_PLUGIN_URL' ) ) {
122
+ define( 'WPSTG_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
123
  }
124
 
125
+ if( !defined( 'WPSTG_NAME' ) ) {
126
+ define( 'WPSTG_NAME', 'WP Staging' );
 
127
  }
128
 
129
+ if( !defined( 'WPSTG_SLUG' ) ) {
130
+ define( 'WPSTG_SLUG', 'wp-staging' );
 
 
 
 
131
  }
132
  }
133
 
143
  require_once WPSTG_PLUGIN_DIR . 'includes/logger.php';
144
  require_once WPSTG_PLUGIN_DIR . 'includes/scripts.php';
145
  require_once WPSTG_PLUGIN_DIR . 'includes/staging-functions.php';
146
+ if( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
147
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/settings/register-settings.php';
148
  $wpstg_options = wpstg_get_settings(); // Load it on top of all
149
+ require_once WPSTG_PLUGIN_DIR . 'includes/install.php';
150
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/admin-actions.php';
151
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/admin-notices.php';
152
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/admin-footer.php';
155
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/welcome.php';
156
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/settings/display-settings.php';
157
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/settings/contextual-help.php';
 
158
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/tools.php';
159
  require_once WPSTG_PLUGIN_DIR . 'includes/admin/upload-functions.php';
160
  require_once WPSTG_PLUGIN_DIR . 'includes/class-wpstg-license-handler.php';
166
  }
167
  }
168
 
169
+ public static function wpstg_activation( $networkwide ) {
170
+ global $wpdb;
171
+
172
+ if( function_exists( 'is_multisite' ) && is_multisite() ) {
173
+ // check if it is a network activation - if so, run the activation function for each blog id
174
+ if( $networkwide ) {
175
+ $old_blog = $wpdb->blogid;
176
+ // Get all blog ids
177
+ $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
178
+ foreach ( $blogids as $blog_id ) {
179
+ switch_to_blog( $blog_id );
180
+ wpstg_install();
181
+ }
182
+ switch_to_blog( $old_blog );
183
+ return;
184
+ }
185
+ }
186
+ wpstg_install();
187
+ }
188
+
189
  /**
190
  * Loads the plugin language files
191
  *
195
  */
196
  public function load_textdomain() {
197
  // Set filter for plugin's languages directory
198
+ $wpstg_lang_dir = dirname( plugin_basename( WPSTG_PLUGIN_FILE ) ) . '/languages/';
199
+ $wpstg_lang_dir = apply_filters( 'wpstg_languages_directory', $wpstg_lang_dir );
200
 
201
  // Traditional WordPress plugin locale filter
202
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'wpstg' );
203
+ $mofile = sprintf( '%1$s-%2$s.mo', 'wpstg', $locale );
204
 
205
  // Setup paths to current locale file
206
  $mofile_local = $wpstg_lang_dir . $mofile;
207
  $mofile_global = WP_LANG_DIR . '/wpstg/' . $mofile;
208
 
209
+ if( file_exists( $mofile_global ) ) {
210
  // Look in global /wp-content/languages/WPSTG folder
211
+ load_textdomain( 'wpstg', $mofile_global );
212
+ } elseif( file_exists( $mofile_local ) ) {
213
  // Look in local /wp-content/plugins/wp-staging/languages/ folder
214
+ load_textdomain( 'wpstg', $mofile_local );
215
  } else {
216
  // Load the default language files
217
+ load_plugin_textdomain( 'wpstg', false, $wpstg_lang_dir );
218
  }
219
  }
220
 
231
 
232
  global $wpstg;
233
 
234
+ if( !is_null( $wpstg ) ) {
235
  return $wpstg;
236
  }
237
 
240
  //WPSTG();
241
  }
242
 
243
+ add_action( 'plugins_loaded', 'wp_staging_loaded' );
244
 
245
  /* function WPSTG() {
246
  global $wpstg;
254
  } */
255
 
256
  // Deactivate WPSTG (Pro)
257
+ add_action( 'activated_plugin', array('WPSTG_Utils', 'deactivate_other_instances') );