-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
55 lines (49 loc) · 1.39 KB
/
uninstall.php
File metadata and controls
55 lines (49 loc) · 1.39 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
<?php
/**
* Plugin Deinstallation: Bereinigung aller Plugin-Daten.
*
* Wird von WordPress ausgeführt wenn das Plugin deinstalliert wird.
* Nur aktiv wenn die Einstellung „Daten löschen" aktiviert ist.
*
* @package OpenDataWizard
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Nur löschen wenn die Option gesetzt ist (Opt-in Datenlöschung).
$odw_settings = (array) get_option( 'odw_settings', array() );
if ( empty( $odw_settings['delete_on_uninstall'] ) ) {
return;
}
// Alle odw_dataset Posts inkl. Postmeta löschen.
$odw_post_ids = get_posts(
array(
'post_type' => 'odw_dataset',
'post_status' => 'any',
'posts_per_page' => -1,
'fields' => 'ids',
)
);
foreach ( $odw_post_ids as $odw_pid ) {
wp_delete_post( (int) $odw_pid, true );
}
// Plugin-Optionen löschen.
delete_option( 'odw_settings' );
delete_option( 'odw_demo_post_id' );
delete_option( 'odw_show_welcome' );
// Transients bereinigen.
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
'_transient_odw_%'
)
);
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
'_transient_timeout_odw_%'
)
);