Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/deprecated/3.10.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
defined( 'ABSPATH' ) || exit;
4
+
5
+
class_alias( '\WP_Rocket\deprecated\Engine\Media\Embeds\EmbedsSubscriber', '\WP_Rocket\Engine\Media\Embeds\EmbedsSubscriber' );
6
+
class_alias( '\WP_Rocket\Engine\Admin\Database\Optimization','\WP_Rocket\Admin\Database\Optimization' );
7
+
class_alias( '\WP_Rocket\Engine\Admin\Database\OptimizationProcess','\WP_Rocket\Admin\Database\Optimization_Process' );
8
+
class_alias( '\WP_Rocket\Engine\Admin\Database\ServiceProvider','\WP_Rocket\ServiceProvider\Database' );
9
+
class_alias( '\WP_Rocket\Engine\Admin\Database\Subscriber','\WP_Rocket\Subscriber\Admin\Database\Optimization_Subscriber' );
10
+
11
+
/**
12
+
* Maybe reset opcache after WP Rocket update.
13
+
*
14
+
* @since 3.10.8 deprecated
15
+
* @since 3.1
16
+
* @author Grégory Viguier
17
+
*
18
+
* @param object $wp_upgrader Plugin_Upgrader instance.
19
+
* @param array $hook_extra {
20
+
* Array of bulk item update data.
21
+
*
22
+
* @type string $action Type of action. Default 'update'.
23
+
* @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
24
+
* @type bool $bulk Whether the update process is a bulk update. Default true.
25
+
* @type array $plugins Array of the basename paths of the plugins' main files.
26
+
* }
27
+
*/
28
+
function rocket_maybe_reset_opcache( $wp_upgrader, $hook_extra ) {
29
+
_deprecated_function( __FUNCTION__ . '()', '3.10.8' );
30
+
static $rocket_path;
31
+
32
+
if ( ! isset( $hook_extra['action'], $hook_extra['type'], $hook_extra['plugins'] ) ) {
33
+
return;
34
+
}
35
+
36
+
if ( 'update' !== $hook_extra['action'] || 'plugin' !== $hook_extra['type'] || ! is_array( $hook_extra['plugins'] ) ) {
37
+
return;
38
+
}
39
+
40
+
$plugins = array_flip( $hook_extra['plugins'] );
41
+
42
+
if ( ! isset( $rocket_path ) ) {
43
+
$rocket_path = plugin_basename( WP_ROCKET_FILE );
44
+
}
45
+
46
+
if ( ! isset( $plugins[ $rocket_path ] ) ) {
47
+
return;
48
+
}
49
+
50
+
rocket_reset_opcache();
51
+
}
52
+
53
+
/**
54
+
* Reset PHP opcache.
55
+
*
56
+
* @since 3.10.8 deprecated
57
+
* @since 3.1
58
+
* @author Grégory Viguier
59
+
*/
60
+
function rocket_reset_opcache() {
61
+
_deprecated_function( __FUNCTION__ . '()', '3.10.8' );
62
+
static $can_reset;
63
+
64
+
/**
65
+
* Triggers before WP Rocket tries to reset OPCache
66
+
*
67
+
* @since 3.2.5
68
+
* @author Remy Perona
69
+
*/
70
+
do_action( 'rocket_before_reset_opcache' );
71
+
72
+
if ( ! isset( $can_reset ) ) {
73
+
if ( ! function_exists( 'opcache_reset' ) ) {
74
+
$can_reset = false;
75
+
76
+
return false;
77
+
}
78
+
79
+
$restrict_api = ini_get( 'opcache.restrict_api' );
80
+
81
+
if ( $restrict_api && strpos( __FILE__, $restrict_api ) !== 0 ) {
82
+
$can_reset = false;
83
+
84
+
return false;
85
+
}
86
+
87
+
$can_reset = true;
88
+
}
89
+
90
+
if ( ! $can_reset ) {
91
+
return false;
92
+
}
93
+
94
+
$opcache_reset = opcache_reset();
95
+
96
+
/**
97
+
* Triggers after WP Rocket tries to reset OPCache
98
+
*
99
+
* @since 3.2.5
100
+
* @author Remy Perona
101
+
*/
102
+
do_action( 'rocket_after_reset_opcache' );
103
+
104
+
return $opcache_reset;
105
+
}
106
+
107
+
/**
108
+
* This notice is displayed after purging OPcache
109
+
*
110
+
* @since 3.10.8 deprecated
111
+
* @since 3.4.1
112
+
* @author Soponar Cristina
113
+
*/
114
+
function rocket_opcache_purge_result() {
115
+
_deprecated_function( __FUNCTION__ . '()', '3.10.8' );
116
+
117
+
if ( ! current_user_can( 'rocket_purge_opcache' ) ) {
118
+
return;
119
+
}
120
+
121
+
if ( ! is_admin() ) {
122
+
return;
123
+
}
124
+
125
+
$user_id = get_current_user_id();
126
+
$notice = get_transient( $user_id . '_opcache_purge_result' );
127
+
if ( ! $notice ) {
128
+
return;
129
+
}
130
+
131
+
delete_transient( $user_id . '_opcache_purge_result' );
132
+
133
+
rocket_notice_html(
134
+
[
135
+
'status' => $notice['result'],
136
+
'message' => $notice['message'],
137
+
]
138
+
);
139
+
}
140
+
141
+
/**
142
+
* Purge OPCache content in Admin Bar
143
+
*
144
+
* @since 3.10.8 deprecated
145
+
* @since 2.7
146
+
*/
147
+
function do_admin_post_rocket_purge_opcache() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
148
+
_deprecated_function( __FUNCTION__ . '()', '3.10.8' );
149
+
150
+
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'rocket_purge_opcache' ) ) {
151
+
wp_nonce_ays( '' );
152
+
}
153
+
154
+
if ( ! current_user_can( 'rocket_purge_opcache' ) ) {
155
+
return;
156
+
}
157
+
158
+
$reset_opcache = rocket_reset_opcache();
159
+
160
+
if ( ! $reset_opcache ) {
161
+
$op_purge_result = [
162
+
'result' => 'error',
163
+
'message' => __( 'OPcache purge failed.', 'rocket' ),
164
+
];
165
+
} else {
166
+
$op_purge_result = [
167
+
'result' => 'success',
168
+
'message' => __( 'OPcache successfully purged', 'rocket' ),
169
+
];
170
+
}
171
+
172
+
set_transient( get_current_user_id() . '_opcache_purge_result', $op_purge_result );
173
+
174
+
wp_safe_redirect( esc_url_raw( wp_get_referer() ) );
175
+
die();
176
+
}
177
+