Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/ThirdParty/Hostings/WPXCloud.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace WP_Rocket\ThirdParty\Hostings;
4
+
5
+
use WP_Rocket\ThirdParty\ReturnTypesTrait;
6
+
7
+
/**
8
+
* Compatibility class for WPX Cloud.
9
+
*/
10
+
class WPXCloud extends AbstractNoCacheHost {
11
+
/**
12
+
* Array of events this subscriber wants to listen to.
13
+
*
14
+
* @return array
15
+
*/
16
+
public static function get_subscribed_events(): array {
17
+
return [
18
+
'rocket_varnish_ip' => 'varnish_ip',
19
+
'rocket_display_input_varnish_auto_purge' => 'return_false',
20
+
'do_rocket_varnish_http_purge' => 'return_true',
21
+
'rocket_varnish_field_settings' => 'varnish_addon_title',
22
+
'after_rocket_htaccess_rules' => 'append_cache_control_header',
23
+
];
24
+
}
25
+
26
+
/**
27
+
* Adds WPX Cloud Varnish IP to varnish IPs array
28
+
*
29
+
* @param mixed $varnish_ip Varnish IP.
30
+
* @return array
31
+
*/
32
+
public function varnish_ip( $varnish_ip ): array {
33
+
if ( ! is_array( $varnish_ip ) ) {
34
+
$varnish_ip = (array) $varnish_ip;
35
+
}
36
+
37
+
$varnish_ip[] = '127.0.0.1:6081';
38
+
39
+
return $varnish_ip;
40
+
}
41
+
42
+
/**
43
+
* Displays custom title for the Varnish add-on
44
+
*
45
+
* @param array $settings Array of settings for Varnish.
46
+
* @return array
47
+
*/
48
+
public function varnish_addon_title( array $settings ): array {
49
+
$settings['varnish_auto_purge']['title'] = sprintf(
50
+
// Translators: %s = Hosting name.
51
+
__( 'Your site is hosted on %s, we have enabled Varnish auto-purge for compatibility.', 'rocket' ),
52
+
'WPX'
53
+
);
54
+
55
+
return $settings;
56
+
}
57
+
58
+
/**
59
+
* Append cache control header.
60
+
*
61
+
* @return string
62
+
*/
63
+
public function append_cache_control_header(): string {
64
+
$header = '<IfModule mod_headers.c>' . PHP_EOL;
65
+
$header .= 'Header append Cache-Control " s-maxage=3600, stale-while-revalidate=21600" "expr=%{CONTENT_TYPE} =~ m#text/html#"' . PHP_EOL;
66
+
$header .= '</IfModule>' . PHP_EOL;
67
+
68
+
return $header;
69
+
}
70
+
71
+
/**
72
+
* Performs these actions during the plugin activation.
73
+
*
74
+
* @return void
75
+
*/
76
+
public function activate(): void {
77
+
parent::activate();
78
+
79
+
add_action( 'rocket_activation', [ $this, 'append_cache_control_header_on_activation' ] );
80
+
}
81
+
82
+
/**
83
+
* Append cache control header.
84
+
*
85
+
* @return void
86
+
*/
87
+
public function append_cache_control_header_on_activation(): void {
88
+
add_filter( 'after_rocket_htaccess_rules', [ $this, 'append_cache_control_header' ] );
89
+
}
90
+
}
91
+