Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/Engine/Deactivation/Deactivation.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace WP_Rocket\Engine\Deactivation;
4
+
5
+
use WP_Rocket\Admin\Options;
6
+
use WP_Rocket\Dependencies\League\Container\Argument\Literal\StringArgument;
7
+
use WP_Rocket\Dependencies\League\Container\Container;
8
+
use WP_Rocket\Engine\Admin\Beacon\ServiceProvider as BeaconServiceProvider;
9
+
use WP_Rocket\Engine\Support\ServiceProvider as SupportServiceProvider;
10
+
use WP_Rocket\ServiceProvider\Options as OptionsServiceProvider;
11
+
use WP_Rocket\ThirdParty\Hostings\HostResolver;
12
+
use WP_Rocket\ThirdParty\Hostings\ServiceProvider as HostingsServiceProvider;
13
+
14
+
class Deactivation {
15
+
const DEACTIVATION_ENDPOINT = 'https://api.wp-rocket.me/api/wp-rocket/deactivate-licence.php';
16
+
17
+
/**
18
+
* Aliases in the container for each class that needs to call its deactivate method
19
+
*
20
+
* @var array
21
+
*/
22
+
private static $deactivators = [
23
+
'advanced_cache',
24
+
'capabilities_manager',
25
+
'wp_cache',
26
+
'cloudflare_plugin_subscriber',
27
+
];
28
+
29
+
/**
30
+
* Performs these actions during the plugin deactivation
31
+
*
32
+
* @return void
33
+
*/
34
+
public static function deactivate_plugin() {
35
+
global $is_apache;
36
+
37
+
$container = new Container();
38
+
39
+
$container->add( 'options_api', new Options( 'wp_rocket_' ) );
40
+
$container->add( 'template_path', new StringArgument( rocket_get_constant( 'WP_ROCKET_PATH', '' ) . 'views' ) );
41
+
42
+
$container->addServiceProvider( new OptionsServiceProvider() );
43
+
$container->addServiceProvider( new BeaconServiceProvider() );
44
+
$container->addServiceProvider( new SupportServiceProvider() );
45
+
$container->addServiceProvider( new ServiceProvider() );
46
+
$container->addServiceProvider( new HostingsServiceProvider() );
47
+
48
+
$host_type = HostResolver::get_host_service();
49
+
50
+
if ( ! empty( $host_type ) ) {
51
+
array_unshift( self::$deactivators, $host_type );
52
+
}
53
+
54
+
foreach ( self::$deactivators as $deactivator ) {
55
+
$container->get( $deactivator );
56
+
}
57
+
58
+
if ( ! isset( $_GET['rocket_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['rocket_nonce'] ), 'force_deactivation' ) ) {
59
+
$causes = [];
60
+
61
+
// .htaccess problem.
62
+
if ( $is_apache && ! rocket_direct_filesystem()->is_writable( get_home_path() . '.htaccess' ) ) {
63
+
$causes[] = 'htaccess';
64
+
}
65
+
66
+
/**
67
+
* Filters the causes which can prevent the deactivation of the plugin
68
+
*
69
+
* @since 3.6.3
70
+
*
71
+
* @param array $causes An array of causes to pass to the notice.
72
+
*/
73
+
$causes = (array) apply_filters( 'rocket_prevent_deactivation', $causes );
74
+
75
+
if ( count( $causes ) ) {
76
+
set_transient( get_current_user_id() . '_donotdeactivaterocket', $causes );
77
+
wp_safe_redirect( wp_get_referer() );
78
+
die();
79
+
}
80
+
}
81
+
82
+
// Delete config files.
83
+
rocket_delete_config_file();
84
+
85
+
$sites_number = count( _rocket_get_php_files_in_dir( rocket_get_constant( 'WP_ROCKET_CONFIG_PATH' ) ) );
86
+
87
+
if ( ! $sites_number ) {
88
+
// Delete All WP Rocket rules of the .htaccess file.
89
+
flush_rocket_htaccess( true );
90
+
}
91
+
92
+
// Update customer key & licence.
93
+
wp_remote_get(
94
+
self::DEACTIVATION_ENDPOINT,
95
+
[
96
+
'blocking' => false,
97
+
]
98
+
);
99
+
100
+
// Delete transients.
101
+
delete_transient( 'rocket_check_licence_30' );
102
+
delete_transient( 'rocket_check_licence_1' );
103
+
delete_transient( 'rocket_rucss_as_tables_count' );
104
+
delete_site_transient( 'update_wprocket_response' );
105
+
delete_site_transient( 'wp_rocket_update_data' );
106
+
107
+
// Delete user metadata.
108
+
rocket_renew_box( 'preload_notice' );
109
+
110
+
// Unschedule WP Cron events.
111
+
wp_clear_scheduled_hook( 'rocket_cache_dir_size_check' );
112
+
113
+
/**
114
+
* WP Rocket deactivation.
115
+
*
116
+
* @since 3.6.3 add $sites_count parameter.
117
+
* @since 3.1.5
118
+
*
119
+
* @param int $sites_number Number of WP Rocket config files found.
120
+
*/
121
+
do_action( 'rocket_deactivation', $sites_number );
122
+
}
123
+
}
124
+