PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0-beta1
Elementor Website Builder – more than just a page builder v3.8.0-beta1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / upgrade / manager.php

manager.php in Elementor Website Builder – more than just a page builder 3.8.0-beta1, at core/upgrade/manager.php

90 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Upgrade;
3
4 use Elementor\Core\Base\DB_Upgrades_Manager;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 class Manager extends DB_Upgrades_Manager {
11
12 const INSTALLS_HISTORY_META = 'elementor_install_history';
13
14 // todo: remove in future releases
15 public function should_upgrade() {
16 if ( ( 'elementor' === $this->get_plugin_name() ) && version_compare( get_option( $this->get_version_option_name() ), '2.4.2', '<' ) ) {
17 delete_option( 'elementor_log' );
18 }
19
20 return parent::should_upgrade();
21 }
22
23 public function get_name() {
24 return 'upgrade';
25 }
26
27 public function get_action() {
28 return 'elementor_updater';
29 }
30
31 public function get_plugin_name() {
32 return 'elementor';
33 }
34
35 public function get_plugin_label() {
36 return esc_html__( 'Elementor', 'elementor' );
37 }
38
39 public function get_updater_label() {
40 return esc_html__( 'Elementor Data Updater', 'elementor' );
41 }
42
43 public function get_new_version() {
44 return ELEMENTOR_VERSION;
45 }
46
47 public function get_version_option_name() {
48 return 'elementor_version';
49 }
50
51 public function get_upgrades_class() {
52 return 'Elementor\Core\Upgrade\Upgrades';
53 }
54
55 public static function get_installs_history() {
56 return get_option( self::INSTALLS_HISTORY_META, [] );
57 }
58
59 public static function install_compare( $version, $operator ) {
60 $installs_history = self::get_installs_history();
61
62 return version_compare(
63 key( $installs_history ),
64 $version ? $version : '0.0.0', // when no version assigned
65 $operator
66 );
67 }
68
69 protected function update_db_version() {
70 parent::update_db_version();
71
72 $installs_history = self::get_installs_history();
73
74 $time = time();
75
76 $installs_history[ ELEMENTOR_VERSION ] = $time;
77
78 $old_version = $this->get_current_version();
79
80 // If there was an old version of Elementor, and there's no record for that install yet
81 if ( $old_version && empty( $installs_history[ $old_version ] ) ) {
82 $installs_history[ $old_version ] = $installs_history[ ELEMENTOR_VERSION ] - 1;
83 }
84
85 uksort( $installs_history, 'version_compare' );
86
87 update_option( self::INSTALLS_HISTORY_META, $installs_history );
88 }
89 }
90