All-in-One WP Migration - Version 7.46

Version Description

Added

  • Support custom themes directory
Download this release

Release Info

Developer bangelov
Plugin Icon 128x128 All-in-One WP Migration
Version 7.46
Comparing to
See all releases

Code changes from version 7.45 to 7.46

all-in-one-wp-migration.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
6
  * Author: ServMask
7
  * Author URI: https://servmask.com/
8
- * Version: 7.45
9
  * Text Domain: all-in-one-wp-migration
10
  * Domain Path: /languages
11
  * Network: True
@@ -57,9 +57,6 @@ define( 'AI1WM_STORAGE_URL', plugins_url( 'storage', AI1WM_PLUGIN_BASENAME ) );
57
  // Plugin Backups URL
58
  define( 'AI1WM_BACKUPS_URL', content_url( 'ai1wm-backups', AI1WM_PLUGIN_BASENAME ) );
59
 
60
- // Themes Absolute Path
61
- define( 'AI1WM_THEMES_PATH', get_theme_root() );
62
-
63
  // Include constants
64
  require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php';
65
 
5
  * Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
6
  * Author: ServMask
7
  * Author URI: https://servmask.com/
8
+ * Version: 7.46
9
  * Text Domain: all-in-one-wp-migration
10
  * Domain Path: /languages
11
  * Network: True
57
  // Plugin Backups URL
58
  define( 'AI1WM_BACKUPS_URL', content_url( 'ai1wm-backups', AI1WM_PLUGIN_BASENAME ) );
59
 
 
 
 
60
  // Include constants
61
  require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php';
62
 
constants.php CHANGED
@@ -35,7 +35,7 @@ define( 'AI1WM_DEBUG', false );
35
  // ==================
36
  // = Plugin Version =
37
  // ==================
38
- define( 'AI1WM_VERSION', '7.45' );
39
 
40
  // ===============
41
  // = Plugin Name =
@@ -162,6 +162,11 @@ define( 'AI1WM_MEDIA_LIST_NAME', 'media.list' );
162
  // =============================
163
  define( 'AI1WM_PLUGINS_LIST_NAME', 'plugins.list' );
164
 
 
 
 
 
 
165
  // ============================
166
  // = Archive Tables List Name =
167
  // ============================
35
  // ==================
36
  // = Plugin Version =
37
  // ==================
38
+ define( 'AI1WM_VERSION', '7.46' );
39
 
40
  // ===============
41
  // = Plugin Name =
162
  // =============================
163
  define( 'AI1WM_PLUGINS_LIST_NAME', 'plugins.list' );
164
 
165
+ // ============================
166
+ // = Archive Themes List Name =
167
+ // ============================
168
+ define( 'AI1WM_THEMES_LIST_NAME', 'themes.list' );
169
+
170
  // ============================
171
  // = Archive Tables List Name =
172
  // ============================
functions.php CHANGED
@@ -130,6 +130,16 @@ function ai1wm_plugins_list_path( $params ) {
130
  return ai1wm_storage_path( $params ) . DIRECTORY_SEPARATOR . AI1WM_PLUGINS_LIST_NAME;
131
  }
132
 
 
 
 
 
 
 
 
 
 
 
133
  /**
134
  * Get tables.list absolute path
135
  *
@@ -1345,13 +1355,13 @@ function ai1wm_write( $handle, $content ) {
1345
  /**
1346
  * Read contents from a file
1347
  *
1348
- * @param resource $handle File handle to read from
1349
- * @param string $filesize File size
1350
- * @return integer
1351
  * @throws Ai1wm_Not_Readable_Exception
1352
  */
1353
- function ai1wm_read( $handle, $filesize ) {
1354
- $read_result = @fread( $handle, $filesize );
1355
  if ( false === $read_result ) {
1356
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1357
  throw new Ai1wm_Not_Readable_Exception( sprintf( __( 'Unable to read file: %s. <a href="https://help.servmask.com/knowledgebase/invalid-file-permissions/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
@@ -1364,7 +1374,9 @@ function ai1wm_read( $handle, $filesize ) {
1364
  /**
1365
  * Seeks on a file pointer
1366
  *
1367
- * @param string $handle File handle to seeks
 
 
1368
  * @return integer
1369
  */
1370
  function ai1wm_seek( $handle, $offset, $mode = SEEK_SET ) {
@@ -1379,9 +1391,9 @@ function ai1wm_seek( $handle, $offset, $mode = SEEK_SET ) {
1379
  }
1380
 
1381
  /**
1382
- * Tells on a file pointer
1383
  *
1384
- * @param string $handle File handle to tells
1385
  * @return integer
1386
  */
1387
  function ai1wm_tell( $handle ) {
@@ -1395,6 +1407,25 @@ function ai1wm_tell( $handle ) {
1395
  return $tell_result;
1396
  }
1397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1398
  /**
1399
  * Closes a file handle
1400
  *
@@ -1612,6 +1643,24 @@ function ai1wm_get_filters( $tag ) {
1612
  return $filters;
1613
  }
1614
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1615
  /**
1616
  * Get WordPress plugins directory
1617
  *
130
  return ai1wm_storage_path( $params ) . DIRECTORY_SEPARATOR . AI1WM_PLUGINS_LIST_NAME;
131
  }
132
 
133
+ /**
134
+ * Get themes.list absolute path
135
+ *
136
+ * @param array $params Request parameters
137
+ * @return string
138
+ */
139
+ function ai1wm_themes_list_path( $params ) {
140
+ return ai1wm_storage_path( $params ) . DIRECTORY_SEPARATOR . AI1WM_THEMES_LIST_NAME;
141
+ }
142
+
143
  /**
144
  * Get tables.list absolute path
145
  *
1355
  /**
1356
  * Read contents from a file
1357
  *
1358
+ * @param resource $handle File handle to read from
1359
+ * @param integer $length Up to length number of bytes read
1360
+ * @return string
1361
  * @throws Ai1wm_Not_Readable_Exception
1362
  */
1363
+ function ai1wm_read( $handle, $length ) {
1364
+ $read_result = @fread( $handle, $length );
1365
  if ( false === $read_result ) {
1366
  if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1367
  throw new Ai1wm_Not_Readable_Exception( sprintf( __( 'Unable to read file: %s. <a href="https://help.servmask.com/knowledgebase/invalid-file-permissions/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
1374
  /**
1375
  * Seeks on a file pointer
1376
  *
1377
+ * @param resource $handle File handle
1378
+ * @param integer $offset File offset
1379
+ * @param integer $mode Offset mode
1380
  * @return integer
1381
  */
1382
  function ai1wm_seek( $handle, $offset, $mode = SEEK_SET ) {
1391
  }
1392
 
1393
  /**
1394
+ * Returns the current position of the file read/write pointer
1395
  *
1396
+ * @param resource $handle File handle
1397
  * @return integer
1398
  */
1399
  function ai1wm_tell( $handle ) {
1407
  return $tell_result;
1408
  }
1409
 
1410
+ /**
1411
+ * Write fields to a file
1412
+ *
1413
+ * @param resource $handle File handle to write to
1414
+ * @param array $fields Fields to write to the file
1415
+ * @return integer
1416
+ * @throws Ai1wm_Not_Writable_Exception
1417
+ */
1418
+ function ai1wm_putcsv( $handle, $fields ) {
1419
+ $write_result = @fputcsv( $handle, $fields );
1420
+ if ( false === $write_result ) {
1421
+ if ( ( $meta = stream_get_meta_data( $handle ) ) ) {
1422
+ throw new Ai1wm_Not_Writable_Exception( sprintf( __( 'Unable to write to: %s. <a href="https://help.servmask.com/knowledgebase/invalid-file-permissions/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), $meta['uri'] ) );
1423
+ }
1424
+ }
1425
+
1426
+ return $write_result;
1427
+ }
1428
+
1429
  /**
1430
  * Closes a file handle
1431
  *
1643
  return $filters;
1644
  }
1645
 
1646
+ /**
1647
+ * Get WordPress plugins directories
1648
+ *
1649
+ * @return array
1650
+ */
1651
+ function ai1wm_get_themes_dirs() {
1652
+ $theme_dirs = array();
1653
+ foreach ( search_theme_directories() as $theme_name => $theme_info ) {
1654
+ if ( isset( $theme_info['theme_root'] ) ) {
1655
+ if ( ! in_array( $theme_info['theme_root'], $theme_dirs ) ) {
1656
+ $theme_dirs[] = untrailingslashit( $theme_info['theme_root'] );
1657
+ }
1658
+ }
1659
+ }
1660
+
1661
+ return $theme_dirs;
1662
+ }
1663
+
1664
  /**
1665
  * Get WordPress plugins directory
1666
  *
lib/controller/class-ai1wm-main-controller.php CHANGED
@@ -158,10 +158,12 @@ class Ai1wm_Main_Controller {
158
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Content::execute', 100 );
159
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Media::execute', 110 );
160
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Plugins::execute', 120 );
161
- add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Tables::execute', 130 );
 
162
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Content::execute', 150 );
163
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Media::execute', 160 );
164
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Plugins::execute', 170 );
 
165
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Database::execute', 200 );
166
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Database_File::execute', 220 );
167
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Download::execute', 250 );
158
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Content::execute', 100 );
159
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Media::execute', 110 );
160
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Plugins::execute', 120 );
161
+ add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Themes::execute', 130 );
162
+ add_filter( 'ai1wm_export', 'Ai1wm_Export_Enumerate_Tables::execute', 140 );
163
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Content::execute', 150 );
164
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Media::execute', 160 );
165
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Plugins::execute', 170 );
166
+ add_filter( 'ai1wm_export', 'Ai1wm_Export_Themes::execute', 180 );
167
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Database::execute', 200 );
168
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Database_File::execute', 220 );
169
  add_filter( 'ai1wm_export', 'Ai1wm_Export_Download::execute', 250 );
lib/model/class-ai1wm-extensions.php CHANGED
@@ -228,7 +228,7 @@ class Ai1wm_Extensions {
228
  'check' => AI1WMME_PLUGIN_CHECK,
229
  'basename' => AI1WMME_PLUGIN_BASENAME,
230
  'version' => AI1WMME_VERSION,
231
- 'requires' => '4.12',
232
  'short' => AI1WMME_PLUGIN_SHORT,
233
  );
234
  }
228
  'check' => AI1WMME_PLUGIN_CHECK,
229
  'basename' => AI1WMME_PLUGIN_BASENAME,
230
  'version' => AI1WMME_VERSION,
231
+ 'requires' => '4.14',
232
  'short' => AI1WMME_PLUGIN_SHORT,
233
  );
234
  }
lib/model/export/class-ai1wm-export-config.php CHANGED
@@ -132,7 +132,7 @@ class Ai1wm_Export_Config {
132
  $config['Plugin'] = array( 'Version' => AI1WM_VERSION );
133
 
134
  // Set WordPress version and content
135
- $config['WordPress'] = array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR, 'Plugins' => ai1wm_get_plugins_dir(), 'Themes' => get_theme_root(), 'Uploads' => ai1wm_get_uploads_dir(), 'UploadsURL' => ai1wm_get_uploads_url() );
136
 
137
  // Set database version
138
  $config['Database'] = array( 'Version' => $mysql->version(), 'Charset' => DB_CHARSET, 'Collate' => DB_COLLATE, 'Prefix' => $table_prefix );
132
  $config['Plugin'] = array( 'Version' => AI1WM_VERSION );
133
 
134
  // Set WordPress version and content
135
+ $config['WordPress'] = array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR, 'Plugins' => ai1wm_get_plugins_dir(), 'Themes' => ai1wm_get_themes_dirs(), 'Uploads' => ai1wm_get_uploads_dir(), 'UploadsURL' => ai1wm_get_uploads_url() );
136
 
137
  // Set database version
138
  $config['Database'] = array( 'Version' => $mysql->version(), 'Charset' => DB_CHARSET, 'Collate' => DB_COLLATE, 'Prefix' => $table_prefix );
lib/model/export/class-ai1wm-export-enumerate-content.php CHANGED
@@ -31,7 +31,7 @@ class Ai1wm_Export_Enumerate_Content {
31
 
32
  public static function execute( $params ) {
33
 
34
- $exclude_filters = array( ai1wm_get_uploads_dir(), ai1wm_get_plugins_dir() );
35
 
36
  // Get total content files count
37
  if ( isset( $params['total_content_files_count'] ) ) {
@@ -55,17 +55,6 @@ class Ai1wm_Export_Enumerate_Content {
55
  $exclude_filters[] = 'cache';
56
  }
57
 
58
- // Exclude themes
59
- if ( isset( $params['options']['no_themes'] ) ) {
60
- $exclude_filters[] = 'themes';
61
- } elseif ( isset( $params['options']['no_inactive_themes'] ) ) {
62
- foreach ( search_theme_directories() as $theme_name => $theme_info ) {
63
- if ( ! in_array( $theme_name, array( get_template(), get_stylesheet() ) ) ) {
64
- $exclude_filters[] = 'themes' . DIRECTORY_SEPARATOR . $theme_name;
65
- }
66
- }
67
- }
68
-
69
  // Exclude must-use plugins
70
  if ( isset( $params['options']['no_muplugins'] ) ) {
71
  $exclude_filters[] = 'mu-plugins';
31
 
32
  public static function execute( $params ) {
33
 
34
+ $exclude_filters = array_merge( array( ai1wm_get_uploads_dir(), ai1wm_get_plugins_dir() ), ai1wm_get_themes_dirs() );
35
 
36
  // Get total content files count
37
  if ( isset( $params['total_content_files_count'] ) ) {
55
  $exclude_filters[] = 'cache';
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
58
  // Exclude must-use plugins
59
  if ( isset( $params['options']['no_muplugins'] ) ) {
60
  $exclude_filters[] = 'mu-plugins';
lib/model/export/class-ai1wm-export-enumerate-themes.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2014-2020 ServMask Inc.
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
19
+ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
20
+ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
21
+ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
22
+ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
+ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
+ */
25
+
26
+ if ( ! defined( 'ABSPATH' ) ) {
27
+ die( 'Kangaroos cannot jump here' );
28
+ }
29
+
30
+ class Ai1wm_Export_Enumerate_Themes {
31
+
32
+ public static function execute( $params ) {
33
+
34
+ $exclude_filters = array();
35
+
36
+ // Get total themes files count
37
+ if ( isset( $params['total_themes_files_count'] ) ) {
38
+ $total_themes_files_count = (int) $params['total_themes_files_count'];
39
+ } else {
40
+ $total_themes_files_count = 1;
41
+ }
42
+
43
+ // Get total themes files size
44
+ if ( isset( $params['total_themes_files_size'] ) ) {
45
+ $total_themes_files_size = (int) $params['total_themes_files_size'];
46
+ } else {
47
+ $total_themes_files_size = 1;
48
+ }
49
+
50
+ // Set progress
51
+ Ai1wm_Status::info( __( 'Retrieving a list of WordPress theme files...', AI1WM_PLUGIN_NAME ) );
52
+
53
+ // Exclude inactive themes
54
+ if ( isset( $params['options']['no_inactive_themes'] ) ) {
55
+ foreach ( search_theme_directories() as $theme_name => $theme_info ) {
56
+ if ( ! in_array( $theme_name, array( get_template(), get_stylesheet() ) ) ) {
57
+ if ( isset( $theme_info['theme_root'] ) ) {
58
+ $exclude_filters[] = $theme_info['theme_root'] . DIRECTORY_SEPARATOR . $theme_name;
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ // Exclude selected files
65
+ if ( isset( $params['options']['exclude_files'], $params['excluded_files'] ) ) {
66
+ if ( ( $excluded_files = explode( ',', $params['excluded_files'] ) ) ) {
67
+ foreach ( $excluded_files as $excluded_path ) {
68
+ $exclude_filters[] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . untrailingslashit( $excluded_path );
69
+ }
70
+ }
71
+ }
72
+
73
+ // Create themes list file
74
+ $themes_list = ai1wm_open( ai1wm_themes_list_path( $params ), 'w' );
75
+
76
+ // Enumerate over themes directory
77
+ if ( isset( $params['options']['no_themes'] ) === false ) {
78
+ foreach ( ai1wm_get_themes_dirs() as $theme_dir ) {
79
+ if ( is_dir( $theme_dir ) ) {
80
+
81
+ // Iterate over themes directory
82
+ $iterator = new Ai1wm_Recursive_Directory_Iterator( $theme_dir );
83
+
84
+ // Exclude themes files
85
+ $iterator = new Ai1wm_Recursive_Exclude_Filter( $iterator, apply_filters( 'ai1wm_exclude_themes_from_export', $exclude_filters ) );
86
+
87
+ // Recursively iterate over themes directory
88
+ $iterator = new Ai1wm_Recursive_Iterator_Iterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
89
+
90
+ // Write path line
91
+ foreach ( $iterator as $item ) {
92
+ if ( $item->isFile() ) {
93
+ if ( ai1wm_putcsv( $themes_list, array( $iterator->getPathname(), $iterator->getSubPathname(), $iterator->getSize(), $iterator->getMTime() ) ) ) {
94
+ $total_themes_files_count++;
95
+
96
+ // Add current file size
97
+ $total_themes_files_size += $iterator->getSize();
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ // Set progress
106
+ Ai1wm_Status::info( __( 'Done retrieving a list of WordPress theme files.', AI1WM_PLUGIN_NAME ) );
107
+
108
+ // Set total themes files count
109
+ $params['total_themes_files_count'] = $total_themes_files_count;
110
+
111
+ // Set total themes files size
112
+ $params['total_themes_files_size'] = $total_themes_files_size;
113
+
114
+ // Close the themes list file
115
+ ai1wm_close( $themes_list );
116
+
117
+ return $params;
118
+ }
119
+ }
lib/model/export/class-ai1wm-export-themes.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2014-2020 ServMask Inc.
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
19
+ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
20
+ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
21
+ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
22
+ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
23
+ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
24
+ */
25
+
26
+ if ( ! defined( 'ABSPATH' ) ) {
27
+ die( 'Kangaroos cannot jump here' );
28
+ }
29
+
30
+ class Ai1wm_Export_Themes {
31
+
32
+ public static function execute( $params ) {
33
+
34
+ // Set archive bytes offset
35
+ if ( isset( $params['archive_bytes_offset'] ) ) {
36
+ $archive_bytes_offset = (int) $params['archive_bytes_offset'];
37
+ } else {
38
+ $archive_bytes_offset = ai1wm_archive_bytes( $params );
39
+ }
40
+
41
+ // Set file bytes offset
42
+ if ( isset( $params['file_bytes_offset'] ) ) {
43
+ $file_bytes_offset = (int) $params['file_bytes_offset'];
44
+ } else {
45
+ $file_bytes_offset = 0;
46
+ }
47
+
48
+ // Set themes bytes offset
49
+ if ( isset( $params['themes_bytes_offset'] ) ) {
50
+ $themes_bytes_offset = (int) $params['themes_bytes_offset'];
51
+ } else {
52
+ $themes_bytes_offset = 0;
53
+ }
54
+
55
+ // Get processed files size
56
+ if ( isset( $params['processed_files_size'] ) ) {
57
+ $processed_files_size = (int) $params['processed_files_size'];
58
+ } else {
59
+ $processed_files_size = 0;
60
+ }
61
+
62
+ // Get total themes files size
63
+ if ( isset( $params['total_themes_files_size'] ) ) {
64
+ $total_themes_files_size = (int) $params['total_themes_files_size'];
65
+ } else {
66
+ $total_themes_files_size = 1;
67
+ }
68
+
69
+ // Get total themes files count
70
+ if ( isset( $params['total_themes_files_count'] ) ) {
71
+ $total_themes_files_count = (int) $params['total_themes_files_count'];
72
+ } else {
73
+ $total_themes_files_count = 1;
74
+ }
75
+
76
+ // What percent of files have we processed?
77
+ $progress = (int) min( ( $processed_files_size / $total_themes_files_size ) * 100, 100 );
78
+
79
+ // Set progress
80
+ Ai1wm_Status::info( sprintf( __( 'Archiving %d theme files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $total_themes_files_count, $progress ) );
81
+
82
+ // Flag to hold if file data has been processed
83
+ $completed = true;
84
+
85
+ // Start time
86
+ $start = microtime( true );
87
+
88
+ // Get themes list file
89
+ $themes_list = ai1wm_open( ai1wm_themes_list_path( $params ), 'r' );
90
+
91
+ // Set the file pointer at the current index
92
+ if ( fseek( $themes_list, $themes_bytes_offset ) !== -1 ) {
93
+
94
+ // Open the archive file for writing
95
+ $archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );
96
+
97
+ // Set the file pointer to the one that we have saved
98
+ $archive->set_file_pointer( $archive_bytes_offset );
99
+
100
+ // Loop over files
101
+ while ( list( $file_abspath, $file_relpath, $file_size, $file_mtime ) = fgetcsv( $themes_list ) ) {
102
+ $file_bytes_written = 0;
103
+
104
+ // Add file to archive
105
+ if ( ( $completed = $archive->add_file( $file_abspath, 'themes' . DIRECTORY_SEPARATOR . $file_relpath, $file_bytes_written, $file_bytes_offset ) ) ) {
106
+ $file_bytes_offset = 0;
107
+
108
+ // Get themes bytes offset
109
+ $themes_bytes_offset = ftell( $themes_list );
110
+ }
111
+
112
+ // Increment processed files size
113
+ $processed_files_size += $file_bytes_written;
114
+
115
+ // What percent of files have we processed?
116
+ $progress = (int) min( ( $processed_files_size / $total_themes_files_size ) * 100, 100 );
117
+
118
+ // Set progress
119
+ Ai1wm_Status::info( sprintf( __( 'Archiving %d theme files...<br />%d%% complete', AI1WM_PLUGIN_NAME ), $total_themes_files_count, $progress ) );
120
+
121
+ // More than 10 seconds have passed, break and do another request
122
+ if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
123
+ if ( ( microtime( true ) - $start ) > $timeout ) {
124
+ $completed = false;
125
+ break;
126
+ }
127
+ }
128
+ }
129
+
130
+ // Get archive bytes offset
131
+ $archive_bytes_offset = $archive->get_file_pointer();
132
+
133
+ // Truncate the archive file
134
+ $archive->truncate();
135
+
136
+ // Close the archive file
137
+ $archive->close();
138
+ }
139
+
140
+ // End of the themes list?
141
+ if ( feof( $themes_list ) ) {
142
+
143
+ // Unset archive bytes offset
144
+ unset( $params['archive_bytes_offset'] );
145
+
146
+ // Unset file bytes offset
147
+ unset( $params['file_bytes_offset'] );
148
+
149
+ // Unset themes bytes offset
150
+ unset( $params['themes_bytes_offset'] );
151
+
152
+ // Unset processed files size
153
+ unset( $params['processed_files_size'] );
154
+
155
+ // Unset total themes files size
156
+ unset( $params['total_themes_files_size'] );
157
+
158
+ // Unset total themes files count
159
+ unset( $params['total_themes_files_count'] );
160
+
161
+ // Unset completed flag
162
+ unset( $params['completed'] );
163
+
164
+ } else {
165
+
166
+ // Set archive bytes offset
167
+ $params['archive_bytes_offset'] = $archive_bytes_offset;
168
+
169
+ // Set file bytes offset
170
+ $params['file_bytes_offset'] = $file_bytes_offset;
171
+
172
+ // Set themes bytes offset
173
+ $params['themes_bytes_offset'] = $themes_bytes_offset;
174
+
175
+ // Set processed files size
176
+ $params['processed_files_size'] = $processed_files_size;
177
+
178
+ // Set total themes files size
179
+ $params['total_themes_files_size'] = $total_themes_files_size;
180
+
181
+ // Set total themes files count
182
+ $params['total_themes_files_count'] = $total_themes_files_count;
183
+
184
+ // Set completed flag
185
+ $params['completed'] = $completed;
186
+ }
187
+
188
+ // Close the themes list file
189
+ ai1wm_close( $themes_list );
190
+
191
+ return $params;
192
+ }
193
+ }
lib/model/import/class-ai1wm-import-content.php CHANGED
@@ -94,8 +94,8 @@ class Ai1wm_Import_Content {
94
  // Set the file pointer to the one that we have saved
95
  $archive->set_file_pointer( $archive_bytes_offset );
96
 
97
- $old_paths = array( 'plugins' );
98
- $new_paths = array( ai1wm_get_plugins_dir() );
99
 
100
  // Set extract paths
101
  foreach ( $blogs as $blog ) {
94
  // Set the file pointer to the one that we have saved
95
  $archive->set_file_pointer( $archive_bytes_offset );
96
 
97
+ $old_paths = array( 'plugins', 'themes' );
98
+ $new_paths = array( ai1wm_get_plugins_dir(), get_theme_root() );
99
 
100
  // Set extract paths
101
  foreach ( $blogs as $blog ) {
loader.php CHANGED
@@ -249,6 +249,10 @@ require_once AI1WM_EXPORT_PATH .
249
  DIRECTORY_SEPARATOR .
250
  'class-ai1wm-export-enumerate-tables.php';
251
 
 
 
 
 
252
  require_once AI1WM_EXPORT_PATH .
253
  DIRECTORY_SEPARATOR .
254
  'class-ai1wm-export-content.php';
@@ -261,6 +265,10 @@ require_once AI1WM_EXPORT_PATH .
261
  DIRECTORY_SEPARATOR .
262
  'class-ai1wm-export-plugins.php';
263
 
 
 
 
 
264
  require_once AI1WM_EXPORT_PATH .
265
  DIRECTORY_SEPARATOR .
266
  'class-ai1wm-export-database.php';
249
  DIRECTORY_SEPARATOR .
250
  'class-ai1wm-export-enumerate-tables.php';
251
 
252
+ require_once AI1WM_EXPORT_PATH .
253
+ DIRECTORY_SEPARATOR .
254
+ 'class-ai1wm-export-enumerate-themes.php';
255
+
256
  require_once AI1WM_EXPORT_PATH .
257
  DIRECTORY_SEPARATOR .
258
  'class-ai1wm-export-content.php';
265
  DIRECTORY_SEPARATOR .
266
  'class-ai1wm-export-plugins.php';
267
 
268
+ require_once AI1WM_EXPORT_PATH .
269
+ DIRECTORY_SEPARATOR .
270
+ 'class-ai1wm-export-themes.php';
271
+
272
  require_once AI1WM_EXPORT_PATH .
273
  DIRECTORY_SEPARATOR .
274
  'class-ai1wm-export-database.php';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: move, transfer, copy, migrate, backup, clone, restore, db migration, wordp
4
  Requires at least: 3.3
5
  Tested up to: 5.8
6
  Requires PHP: 5.2.17
7
- Stable tag: 7.45
8
  License: GPLv2 or later
9
 
10
  Move, transfer, copy, migrate, and backup a site with 1-click. Quick, easy, and reliable.
@@ -108,6 +108,11 @@ Alternatively you can download the plugin using the download button on this page
108
  All-in-One WP Migration **asks for your consent** to collect **requester's email address** when filling plugin's contact form. [GDPR Compliant Privacy Policy](https://www.iubenda.com/privacy-policy/946881)
109
 
110
  == Changelog ==
 
 
 
 
 
111
  = 7.45 =
112
  **Added**
113
 
4
  Requires at least: 3.3
5
  Tested up to: 5.8
6
  Requires PHP: 5.2.17
7
+ Stable tag: 7.46
8
  License: GPLv2 or later
9
 
10
  Move, transfer, copy, migrate, and backup a site with 1-click. Quick, easy, and reliable.
108
  All-in-One WP Migration **asks for your consent** to collect **requester's email address** when filling plugin's contact form. [GDPR Compliant Privacy Policy](https://www.iubenda.com/privacy-policy/946881)
109
 
110
  == Changelog ==
111
+ = 7.46 =
112
+ **Added**
113
+
114
+ * Support custom themes directory
115
+
116
  = 7.45 =
117
  **Added**
118