Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/Engine/Plugin/UpdaterApiTools.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
namespace WP_Rocket\Engine\Plugin;
3
+
4
+
use WP_Rocket\Logger\Logger;
5
+
6
+
/**
7
+
* Trait for the plugin updater.
8
+
*/
9
+
trait UpdaterApiTools {
10
+
/**
11
+
* Get a \WP_Error object to use when the request to WP Rocket’s server fails.
12
+
*
13
+
* @param mixed $data Error data to pass along the \WP_Error object.
14
+
* @return \WP_Error
15
+
*/
16
+
protected function get_request_error( $data = [] ) {
17
+
if ( ! is_array( $data ) ) {
18
+
$data = [
19
+
'response' => $data,
20
+
];
21
+
}
22
+
23
+
Logger::debug(
24
+
'Error when contacting the API.',
25
+
array_merge( [ 'Plugin Information' ], $data )
26
+
);
27
+
28
+
return new \WP_Error(
29
+
$this->request_error_id,
30
+
sprintf(
31
+
// translators: %s is an URL.
32
+
__( 'An unexpected error occurred. Something may be wrong with WP-Rocket.me or this server’s configuration. If you continue to have problems, <a href="%s">contact support</a>.', 'rocket' ),
33
+
$this->get_support_url()
34
+
),
35
+
$data
36
+
);
37
+
}
38
+
39
+
/**
40
+
* Get support URL.
41
+
*
42
+
* @return string
43
+
*/
44
+
protected function get_support_url() {
45
+
return rocket_get_external_url(
46
+
'support',
47
+
[
48
+
'utm_source' => 'wp_plugin',
49
+
'utm_medium' => 'wp_rocket',
50
+
]
51
+
);
52
+
}
53
+
54
+
/**
55
+
* Get a plugin slug, given its full path.
56
+
*
57
+
* @param string $plugin_file Full path to the plugin.
58
+
* @return string
59
+
*/
60
+
protected function get_plugin_slug( $plugin_file ) {
61
+
$plugin_file = trim( $plugin_file, '/' );
62
+
$plugin_slug = explode( '/', $plugin_file );
63
+
$plugin_slug = end( $plugin_slug );
64
+
$plugin_slug = str_replace( '.php', '', $plugin_slug );
65
+
66
+
return $plugin_slug;
67
+
}
68
+
}
69
+