Completed
Push — phpcs/additional-files ( c98a70 )
by
unknown
07:54
created

uninstall.php ➔ jetpack_uninstall()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 39

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 3
nop 0
dl 0
loc 39
rs 8.9848
c 0
b 0
f 0
1
<?php
2
/**
3
 * Functionality that is executed when Jetpack is uninstalled via built-in WordPress commands.
4
 *
5
 * @package Jetpack
6
 */
7
8
use Automattic\Jetpack\Backup\Helper_Script_Manager;
9
use Automattic\Jetpack\Sync\Sender;
10
11
/**
12
 * Uninstall script for Jetpack.
13
 */
14
function jetpack_uninstall() {
15
	if (
16
		! defined( 'WP_UNINSTALL_PLUGIN' )
17
		||
18
		! WP_UNINSTALL_PLUGIN
19
		||
20
		dirname( WP_UNINSTALL_PLUGIN ) !== dirname( plugin_basename( __FILE__ ) )
21
	) {
22
		status_header( 404 );
23
		exit;
24
	}
25
26
	if ( ! defined( 'JETPACK__PLUGIN_DIR' ) ) {
27
		define( 'JETPACK__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
28
	}
29
30
	require JETPACK__PLUGIN_DIR . 'vendor/autoload_packages.php';
31
32
	Jetpack_Options::delete_all_known_options();
33
34
	// Delete all legacy options.
35
	delete_option( 'jetpack_was_activated' );
36
	delete_option( 'jetpack_auto_installed' );
37
	delete_option( 'jetpack_register' );
38
	delete_transient( 'jetpack_register' );
39
40
	// Delete sync options
41
	//
42
	// Do not initialize any listeners.
43
	// Since all the files will be deleted.
44
	// No need to try to sync anything.
45
	add_filter( 'jetpack_sync_modules', '__return_empty_array', 100 );
46
47
	// Jetpack Sync.
48
	Sender::get_instance()->uninstall();
49
50
	// Jetpack Backup: Cleanup any leftover Helper Scripts.
51
	Helper_Script_Manager::delete_all_helper_scripts();
52
}
53
54
jetpack_uninstall();
55