PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.4
Elementor Website Builder – more than just a page builder v4.3.4
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 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 All 457 releases
elementor / core / upgrade / manager.php

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

131 lines 3.0 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 const VERSION_OPTION_NAME = 'elementor_version';
18
19 public static function get_install_history_meta() {
20 return 'elementor_install_history';
21 }
22
23 /**
24 * TODO: Remove in future releases
25 *
26 * @deprecated 3.1.0
27 */
28 public function should_upgrade() {
29 if ( ( 'elementor' === $this->get_plugin_name() ) && version_compare( get_option( $this->get_version_option_name() ), '2.4.2', '<' ) ) {
30 delete_option( 'elementor_log' );
31 }
32
33 return parent::should_upgrade();
34 }
35
36 public function get_name() {
37 return 'upgrade';
38 }
39
40 public function get_action() {
41 return 'elementor_updater';
42 }
43
44 public function get_plugin_name() {
45 return 'elementor';
46 }
47
48 public function get_plugin_label() {
49 return esc_html__( 'Elementor', 'elementor' );
50 }
51
52 public function get_updater_label() {
53 return esc_html__( 'Elementor Data Updater', 'elementor' );
54 }
55
56 public function get_new_version() {
57 return ELEMENTOR_VERSION;
58 }
59
60 public function get_version_option_name() {
61 return self::VERSION_OPTION_NAME;
62 }
63
64 public function get_upgrades_class() {
65 return 'Elementor\Core\Upgrade\Upgrades';
66 }
67
68 public static function get_installs_history() {
69 return get_option( static::get_install_history_meta(), [] );
70 }
71
72 public static function install_compare( $version, $operator ) {
73 $installs_history = self::get_installs_history();
74
75 return version_compare(
76 key( $installs_history ),
77 $version ? $version : '0.0.0', // when no version assigned
78 $operator
79 );
80 }
81
82 protected function update_db_version() {
83 parent::update_db_version();
84
85 $installs_history = self::get_installs_history();
86
87 $time = time();
88
89 $installs_history[ $this->get_new_version() ] = $time;
90
91 $old_version = $this->get_current_version();
92
93 // If there was an old version of Elementor, and there's no record for that install yet
94 if ( $old_version && empty( $installs_history[ $old_version ] ) ) {
95 $installs_history[ $old_version ] = $installs_history[ $this->get_new_version() ] - 1;
96 }
97
98 uksort( $installs_history, 'version_compare' );
99
100 update_option( static::get_install_history_meta(), $installs_history );
101 }
102
103 public static function is_new_installation(): bool {
104 $installs_history = self::get_installs_history();
105
106 return empty( $installs_history ) || static::install_compare( ELEMENTOR_VERSION, '>=' );
107 }
108
109 public static function had_install_prior_to( string $version ): bool {
110 if ( ! $version ) {
111 return false;
112 }
113
114 $installs_history = self::get_installs_history();
115
116 if ( empty( $installs_history ) ) {
117 return false;
118 }
119
120 uksort( $installs_history, 'version_compare' );
121
122 $first_version = array_key_first( $installs_history );
123
124 if ( ! $first_version ) {
125 return false;
126 }
127
128 return version_compare( $first_version, $version, '<' );
129 }
130 }
131