Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/elementor/includes/rollback.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
namespace Elementor;
3
+
4
+
if ( ! defined( 'ABSPATH' ) ) {
5
+
exit; // Exit if accessed directly.
6
+
}
7
+
8
+
/**
9
+
* Elementor rollback.
10
+
*
11
+
* Elementor rollback handler class is responsible for rolling back Elementor to
12
+
* previous version.
13
+
*
14
+
* @since 1.5.0
15
+
*/
16
+
class Rollback {
17
+
18
+
/**
19
+
* Package URL.
20
+
*
21
+
* Holds the package URL.
22
+
*
23
+
* @since 1.5.0
24
+
* @access protected
25
+
*
26
+
* @var string Package URL.
27
+
*/
28
+
protected $package_url;
29
+
30
+
/**
31
+
* Version.
32
+
*
33
+
* Holds the version.
34
+
*
35
+
* @since 1.5.0
36
+
* @access protected
37
+
*
38
+
* @var string Package URL.
39
+
*/
40
+
protected $version;
41
+
42
+
/**
43
+
* Plugin name.
44
+
*
45
+
* Holds the plugin name.
46
+
*
47
+
* @since 1.5.0
48
+
* @access protected
49
+
*
50
+
* @var string Plugin name.
51
+
*/
52
+
protected $plugin_name;
53
+
54
+
/**
55
+
* Plugin slug.
56
+
*
57
+
* Holds the plugin slug.
58
+
*
59
+
* @since 1.5.0
60
+
* @access protected
61
+
*
62
+
* @var string Plugin slug.
63
+
*/
64
+
protected $plugin_slug;
65
+
66
+
/**
67
+
* Rollback constructor.
68
+
*
69
+
* Initializing Elementor rollback.
70
+
*
71
+
* @since 1.5.0
72
+
* @access public
73
+
*
74
+
* @param array $args Optional. Rollback arguments. Default is an empty array.
75
+
*/
76
+
public function __construct( $args = [] ) {
77
+
foreach ( $args as $key => $value ) {
78
+
$this->{$key} = $value;
79
+
}
80
+
}
81
+
82
+
/**
83
+
* Print inline style.
84
+
*
85
+
* Add an inline CSS to the rollback page.
86
+
*
87
+
* @since 1.5.0
88
+
* @access private
89
+
*/
90
+
private function print_inline_style() {
91
+
?>
92
+
<style>
93
+
.wrap {
94
+
overflow: hidden;
95
+
max-width: 850px;
96
+
margin: auto;
97
+
font-family: Courier, monospace;
98
+
}
99
+
100
+
h1 {
101
+
background: #D30C5C;
102
+
text-align: center;
103
+
color: #fff !important;
104
+
padding: 70px !important;
105
+
text-transform: uppercase;
106
+
letter-spacing: 1px;
107
+
}
108
+
109
+
h1 img {
110
+
max-width: 300px;
111
+
display: block;
112
+
margin: auto auto 50px;
113
+
}
114
+
</style>
115
+
<?php
116
+
}
117
+
118
+
/**
119
+
* Apply package.
120
+
*
121
+
* Change the plugin data when WordPress checks for updates. This method
122
+
* modifies package data to update the plugin from a specific URL containing
123
+
* the version package.
124
+
*
125
+
* @since 1.5.0
126
+
* @access protected
127
+
*/
128
+
protected function apply_package() {
129
+
$update_plugins = get_site_transient( 'update_plugins' );
130
+
if ( ! is_object( $update_plugins ) ) {
131
+
$update_plugins = new \stdClass();
132
+
}
133
+
134
+
$plugin_info = new \stdClass();
135
+
$plugin_info->new_version = $this->version;
136
+
$plugin_info->slug = $this->plugin_slug;
137
+
$plugin_info->package = $this->package_url;
138
+
$plugin_info->url = 'https://elementor.com/';
139
+
140
+
$update_plugins->response[ $this->plugin_name ] = $plugin_info;
141
+
142
+
// Remove handle beta testers.
143
+
remove_filter( 'pre_set_site_transient_update_plugins', [ Plugin::instance()->beta_testers, 'check_version' ] );
144
+
145
+
set_site_transient( 'update_plugins', $update_plugins );
146
+
}
147
+
148
+
/**
149
+
* Upgrade.
150
+
*
151
+
* Run WordPress upgrade to rollback Elementor to previous version.
152
+
*
153
+
* @since 1.5.0
154
+
* @access protected
155
+
*/
156
+
protected function upgrade() {
157
+
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
158
+
159
+
$logo_url = ELEMENTOR_ASSETS_URL . 'images/logo-panel.svg';
160
+
161
+
$upgrader_args = [
162
+
'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this->plugin_name ),
163
+
'plugin' => $this->plugin_name,
164
+
'nonce' => 'upgrade-plugin_' . $this->plugin_name,
165
+
'title' => '<img src="' . $logo_url . '" alt="Elementor">' . esc_html__( 'Rollback to Previous Version', 'elementor' ),
166
+
];
167
+
168
+
$this->print_inline_style();
169
+
170
+
$upgrader = new \Plugin_Upgrader( new \Plugin_Upgrader_Skin( $upgrader_args ) );
171
+
$upgrader->upgrade( $this->plugin_name );
172
+
}
173
+
174
+
/**
175
+
* Run.
176
+
*
177
+
* Rollback Elementor to previous versions.
178
+
*
179
+
* @since 1.5.0
180
+
* @access public
181
+
*/
182
+
public function run() {
183
+
$this->apply_package();
184
+
$this->upgrade();
185
+
}
186
+
}
187
+