PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.5
Elementor Website Builder – more than just a page builder v3.25.5
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.25.5, at core/upgrade/manager.php

103 lines 2.5 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 /**
13 * @deprecated 3.17.0
14 */
15 const INSTALLS_HISTORY_META = 'elementor_install_history';
16
17 public static function get_install_history_meta() {
18 return 'elementor_install_history';
19 }
20
21 // todo: remove in future releases
22 public function should_upgrade() {
23 if ( ( 'elementor' === $this->get_plugin_name() ) && version_compare( get_option( $this->get_version_option_name() ), '2.4.2', '<' ) ) {
24 delete_option( 'elementor_log' );
25 }
26
27 return parent::should_upgrade();
28 }
29
30 public function get_name() {
31 return 'upgrade';
32 }
33
34 public function get_action() {
35 return 'elementor_updater';
36 }
37
38 public function get_plugin_name() {
39 return 'elementor';
40 }
41
42 public function get_plugin_label() {
43 return esc_html__( 'Elementor', 'elementor' );
44 }
45
46 public function get_updater_label() {
47 return esc_html__( 'Elementor Data Updater', 'elementor' );
48 }
49
50 public function get_new_version() {
51 return ELEMENTOR_VERSION;
52 }
53
54 public function get_version_option_name() {
55 return 'elementor_version';
56 }
57
58 public function get_upgrades_class() {
59 return 'Elementor\Core\Upgrade\Upgrades';
60 }
61
62 public static function get_installs_history() {
63 return get_option( static::get_install_history_meta(), [] );
64 }
65
66 public static function install_compare( $version, $operator ) {
67 $installs_history = self::get_installs_history();
68
69 return version_compare(
70 key( $installs_history ),
71 $version ? $version : '0.0.0', // when no version assigned
72 $operator
73 );
74 }
75
76 protected function update_db_version() {
77 parent::update_db_version();
78
79 $installs_history = self::get_installs_history();
80
81 $time = time();
82
83 $installs_history[ $this->get_new_version() ] = $time;
84
85 $old_version = $this->get_current_version();
86
87 // If there was an old version of Elementor, and there's no record for that install yet
88 if ( $old_version && empty( $installs_history[ $old_version ] ) ) {
89 $installs_history[ $old_version ] = $installs_history[ $this->get_new_version() ] - 1;
90 }
91
92 uksort( $installs_history, 'version_compare' );
93
94 update_option( static::get_install_history_meta(), $installs_history );
95 }
96
97 public static function is_new_installation() : bool {
98 $installs_history = self::get_installs_history();
99
100 return empty( $installs_history ) || static::install_compare( ELEMENTOR_VERSION, '>=' );
101 }
102 }
103