Completed
Push — feature/reorg ( 560003...ffb278 )
by
unknown
199:35 queued 189:28
created

uninstall.php ➔ jetpack_uninstall()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 3
nop 0
dl 0
loc 37
rs 9.0168
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
		! WP_UNINSTALL_PLUGIN ||
18
		dirname( WP_UNINSTALL_PLUGIN ) !== dirname( plugin_basename( __FILE__ ) )
19
	) {
20
		status_header( 404 );
21
		exit;
22
	}
23
24
	if ( ! defined( 'JETPACK__PLUGIN_DIR' ) ) {
25
		define( 'JETPACK__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
26
	}
27
28
	require JETPACK__PLUGIN_DIR . 'vendor/autoload_packages.php';
29
30
	Jetpack_Options::delete_all_known_options();
31
32
	// Delete all legacy options.
33
	delete_option( 'jetpack_was_activated' );
34
	delete_option( 'jetpack_auto_installed' );
35
	delete_option( 'jetpack_register' );
36
	delete_transient( 'jetpack_register' );
37
38
	// Delete sync options
39
	//
40
	// Do not initialize any listeners.
41
	// Since all the files will be deleted.
42
	// No need to try to sync anything.
43
	add_filter( 'jetpack_sync_modules', '__return_empty_array', 100 );
44
45
	// Jetpack Sync.
46
	Sender::get_instance()->uninstall();
47
48
	// Jetpack Backup: Cleanup any leftover Helper Scripts.
49
	Helper_Script_Manager::delete_all_helper_scripts();
50
}
51
52
jetpack_uninstall();
53