PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 2.1.2
Backup Migration v2.1.2
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / includes / progress / migration.php
backup-backup / includes / progress Last commit date
class-file-progress-storage.php 3 months ago interface-progress-storage.php 3 months ago logger-only.php 3 months ago migration.php 3 months ago staging.php 3 months ago zip.php 3 months ago
migration.php
85 lines
1 <?php
2
3 // Namespace
4 namespace BMI\Plugin\Progress;
5
6 // Use
7 use BMI\Plugin\BMI_Logger AS Logger;
8
9 // Exit on direct access
10 if (!defined('ABSPATH')) exit;
11
12 /**
13 * Main File Restoration/Migration Logs
14 */
15 class BMI_MigrationProgress {
16
17 public $latest;
18 public $progress;
19 public $file;
20 public $muted = false;
21
22 public function __construct($continue = false) {
23
24 if (!file_exists(BMI_BACKUPS)) mkdir(BMI_BACKUPS, 0755, true);
25
26 $this->latest = BMI_BACKUPS . '/latest_migration.' . BMI_LOGS_SUFFIX . '.log';
27 $this->progress = BMI_BACKUPS . '/latest_migration_progress.' . BMI_LOGS_SUFFIX . '.log';
28
29 if (file_exists($this->latest) && $continue === false) {
30 unlink($this->latest);
31 }
32
33 }
34
35 public function start($muted = false) {
36
37 $this->muted = $muted;
38
39 }
40
41 public function mute() {
42
43 $this->muted = true;
44
45 }
46
47 public function unmute() {
48
49 $this->muted = false;
50
51 }
52
53 public function progress($progress = '0') {
54
55 file_put_contents($this->progress, $progress);
56
57 }
58
59 public function log($log = '', $level = 'INFO') {
60
61 $this->file = fopen($this->latest, 'a');
62
63 if (!$this->muted) {
64 if (defined('BMI_USING_CLI_FUNCTIONALITY') && BMI_USING_CLI_FUNCTIONALITY === true) {
65 $log_string = '[' . strtoupper($level) . '] [' . date('Y-m-d H:i:s') . '] [CLI] ' . $log . "\n";
66 } else {
67 $log_string = '[' . strtoupper($level) . '] [' . date('Y-m-d H:i:s') . '] ' . $log . "\n";
68 }
69 fwrite($this->file, $log_string);
70 if (defined('BMI_USING_CLI_FUNCTIONALITY') && BMI_USING_CLI_FUNCTIONALITY === true) {
71 echo esc_html( $log_string );
72 }
73 }
74
75 fclose($this->file);
76 }
77
78 public function end() {
79
80 return true;
81
82 }
83
84 }
85