-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
57 lines (49 loc) · 1.88 KB
/
Copy pathuninstall.php
File metadata and controls
57 lines (49 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php declare( strict_types=1 );
/**
* Uninstall handler. Runs in WordPress's cold uninstall bootstrap — no plugin loaded, only
* WP_UNINSTALL_PLUGIN defined — so it rebuilds the container and delegates cleanup to the installer.
*
* @since 2.0.0
* @version 2.0.0
*
* @package DeepWebSolutions\PluginTemplate
*/
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
/**
* Deletes the plugin's persisted footprint directly, without the framework.
*
* This degraded path clears only the current site; a built install runs the multisite-aware installer.
*
* @since 2.0.0
* @version 2.0.0
*/
function dws_plugin_template_delete_footprint(): void {
$footprint = require __DIR__ . '/config/footprint.php';
foreach ( $footprint['options'] as $option ) {
delete_option( $option );
}
foreach ( $footprint['user_meta'] as $meta_key ) {
delete_metadata( 'user', 0, $meta_key, '', true );
}
}
/*
* The container path needs the same three build artifacts as the entry point's preflight — a partial build
* (vendor/ present but the scoped framework absent) would fatal resolving the installer's scoped classes.
* With any artifact missing the installer is unreachable, so delete the footprint directly rather than
* leaving it behind.
*/
if ( ! is_file( __DIR__ . '/vendor/autoload.php' )
|| ! is_file( __DIR__ . '/dependencies/scoper-autoload.php' )
|| ! is_file( __DIR__ . '/dependencies/ahegyes/wp-framework-bootstrap/functions.php' )
) {
dws_plugin_template_delete_footprint();
return;
}
try {
require_once __DIR__ . '/vendor/autoload.php';
\DeepWebSolutions\PluginTemplate\Plugin::get_instance()->get_installer()->uninstall();
} catch ( \Throwable ) {
// The artifacts exist but the container path still failed (a missing or unparsable scoped class,
// a below-floor PHP runtime) — the framework-free deletes must run so the footprint never survives.
dws_plugin_template_delete_footprint();
}