PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.8.5
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.8.5
4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / compatibility / migrations / migration.php
shopengine / compatibility / migrations Last commit date
direct-checkout.php 3 years ago lang-migration.php 3 years ago migration.php 4 years ago temp-migration.php 4 years ago
migration.php
82 lines
1 <?php
2 namespace ShopEngine\Compatibility\Migrations;
3 defined('ABSPATH') || exit;
4
5 /*
6 Migration::keep_versions('shopengine', '1.2.3');
7
8
9 new Migration('shopengine', 'unique_key', ['\ShonEngine\Class', 'method_name']);
10 */
11
12 class Migration{
13
14 public static $versions_keep_key = '__installed_versions';
15 public static $versions;
16 private $textdomain;
17 private $migration_key;
18 private $migration_class_callback;
19 private $migration_logs;
20 private $migration_logs_key;
21
22 public function init($textdomain, $migration_key, $migration_class_callback){
23 $this->textdomain = $textdomain;
24 $this->migration_key = $migration_key;
25 $this->migration_logs_key = $textdomain . '__' . $textdomain;
26 $this->migration_class_callback = $migration_class_callback;
27
28 $this->process_migration_logs();
29 if(!in_array($this->migration_key, $this->migration_logs['migrations_done'])){
30 $this->run_migration();
31 }
32 }
33
34 public static function set_versions($textdomain, $version){
35 $versions = self::get_versions($textdomain);
36 // need a fallback for < PHP 7.3.1 // https://www.php.net/manual/en/function.array-key-last.php
37 $last_version = array_key_last(self::$versions);
38
39 if($last_version != $version){
40 return;
41 }
42
43 $versions = array_merge($versions, [$version => time()]);
44 $version_keep_key = $textdomain . self::$version_keep_key;
45 update_option($version_keep_key, $versions);
46 }
47
48 public static function get_versions($textdomain){
49 $version_keep_key = $textdomain . self::$version_keep_key;
50 $versions = get_option($version_keep_key, []);
51 return (!is_array($versions) ? [] : $versions);
52 }
53
54 private function run_migration(){
55 call_user_func($this->migration_class_callback);
56 $this->add_migration_logs();
57 }
58
59 private function add_migration_logs(){
60 $this->migration_logs['migrations_done'][] = $this->migration_key;
61 $this->migration_logs['run_last'] = time();
62 $this->migration_logs['run_version'] = \ShopEngine::version();
63
64 update_option($this->migration_logs_key, $this->migration_logs);
65 }
66
67 private function process_migration_logs(){
68 $logs = get_option($this->migration_logs_key);
69 if(empty($logs) || !isset($logs['migrations_done'])){
70 $logs = [
71 'migrations_done' => [],
72 'run_last' => 0,
73 'run_version' => '0',
74 ];
75
76 update_option($this->migration_logs_key, $logs);
77 }
78
79 $this->migration_logs = $logs;
80 }
81
82 }