PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | uninstall.php +63 -0 16.2-beta → 16.3 View file →
@@ -1,0 +1,63 @@
1 +<?php
2 +/**
3 + * Functionality that is executed when Jetpack is uninstalled via built-in WordPress commands.
4 + *
5 + * @package automattic/jetpack
6 + */
7 +
8 +use Automattic\Jetpack\Backup\V0005\Helper_Script_Manager;
9 +use Automattic\Jetpack\Connection\Manager as Connection_Manager;
10 +use Automattic\Jetpack\Sync\Sender;
11 +
12 +if ( ! defined( 'ABSPATH' ) ) {
13 + exit( 0 );
14 +}
15 +
16 +/**
17 + * Uninstall script for Jetpack.
18 + */
19 +function jetpack_uninstall() {
20 + if (
21 + ! defined( 'WP_UNINSTALL_PLUGIN' ) ||
22 + ! WP_UNINSTALL_PLUGIN ||
23 + // @phan-suppress-next-line PhanTypeMismatchArgumentInternal -- If it's defined, it's a string: https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/#method-2-uninstall-php
24 + dirname( WP_UNINSTALL_PLUGIN ) !== dirname( plugin_basename( __FILE__ ) )
25 + ) {
26 + status_header( 404 );
27 + exit( 0 );
28 + }
29 +
30 + if ( ! defined( 'JETPACK__PLUGIN_DIR' ) ) {
31 + define( 'JETPACK__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
32 + }
33 +
34 + require JETPACK__PLUGIN_DIR . 'vendor/autoload_packages.php';
35 +
36 + if ( method_exists( Connection_Manager::class, 'is_ready_for_cleanup' ) && ! Connection_Manager::is_ready_for_cleanup( dirname( plugin_basename( __FILE__ ) ) ) ) {
37 + // There are other active Jetpack plugins, no need for cleanup.
38 + return;
39 + }
40 +
41 + Jetpack_Options::delete_all_known_options();
42 +
43 + // Delete all legacy options.
44 + delete_option( 'jetpack_was_activated' );
45 + delete_option( 'jetpack_auto_installed' );
46 + delete_option( 'jetpack_register' );
47 + delete_transient( 'jetpack_register' );
48 +
49 + // Delete sync options
50 + //
51 + // Do not initialize any listeners.
52 + // Since all the files will be deleted.
53 + // No need to try to sync anything.
54 + add_filter( 'jetpack_sync_modules', '__return_empty_array', 100 );
55 +
56 + // Jetpack Sync.
57 + Sender::get_instance()->uninstall();
58 +
59 + // Jetpack Backup: Cleanup any leftover Helper Scripts.
60 + Helper_Script_Manager::delete_all_helper_scripts();
61 +}
62 +
63 +jetpack_uninstall();