-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.php
38 lines (29 loc) · 1004 Bytes
/
uninstall.php
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
<?php
/**
* Defines our uninstall features of the plugin
* This is a complete plugin removal function. Setting uninstall to true will delete all data from the database
*/
//if uninstall not called from WordPress exit
if ( ! defined( 'wiki_wiki_uninstall' ) )
exit();
// Define a list of settings we need to clear out
$uninstall_options = array();
// Delete the options
foreach ( $uninstall_options['options'] as $option ) {
// Make sure we are only deleting what we want
if ( in_array( $option, $uninstall_options['options'] ) )
delete_option( $option );
}
// Delete the taxonomies and it's terms
foreach ( $uninstall_options['taxonomies'] as $tax ) {
$terms = get_terms( $tax, array(
'fields' => 'ids',
'hide_empty' => false,
) );
// Loop through all the terms in the taxonomie and delete them
foreach ( $terms as $term ) {
// Make sure we are only deleting what we want
if ( in_array( $option, $uninstall_options['taxonomies'] ) )
wp_delete_term( $term, $tax );
}
}