PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
← All changes | App/Helpers/FileBackup.php +7 -5 3.03.5.9 View file →
@@ -5,9 +5,9 @@
5 5 use WPIDE\App\Services\Storage\LocalFileSystem;
6 6 use WPIDE\App\Utils\Exception;
7 7 use const WPIDE\Constants\BACKUPS_DIR;
8 8 use const WPIDE\Constants\BACKUPS_TODAY_DIR;
9 -use const WPIDE\Constants\CONTENT_DIR;
9 +use const WPIDE\Constants\WP_PATH;
10 10
11 11 class FileBackup
12 12 {
13 13
@@ -21,15 +21,17 @@
21 21
22 22 /**
23 23 * @throws \Exception
24 24 */
25 - public static function backup($item, $newContent): bool
25 + public static function backup($item, $newContent, $root = false): bool
26 26 {
27 27 $dir = $item->dir;
28 28 $path = $item->path;
29 29 $name = $item->name;
30 30
31 - $storage = LocalFileSystem::load();
31 + $root_dir = $root ? '/' : LocalFileSystem::getRootDir();
32 +
33 + $storage = LocalFileSystem::load($root_dir);
32 34 $oldStream = $storage->readStream($path);
33 35
34 36 if ($oldStream['stream']) {
35 37
@@ -34,10 +36,10 @@
34 36 if ($oldStream['stream']) {
35 37
36 38 $backupStorage = LocalFileSystem::load(BACKUPS_TODAY_DIR);
37 39
38 - $originalFileDir = CONTENT_DIR . AppConfig::get('file.root') . ltrim($dir, '/');
39 - $originalFileDir = str_replace(ABSPATH, "", $originalFileDir);
40 + $originalFileDir = wp_normalize_path(WP_PATH . $root_dir . '/'. ltrim($dir, '/'));
41 + $originalFileDir = str_replace(wp_normalize_path(WP_PATH), "", $originalFileDir);
40 42 $backupFilePath = BACKUPS_TODAY_DIR . "/" .$originalFileDir;
41 43 $ext = '.'.pathinfo($name, PATHINFO_EXTENSION);
42 44
43 45 if (!is_dir($backupFilePath)) {