forked from hearvox/postscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
executable file
·84 lines (72 loc) · 1.78 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* Fired when the plugin is uninstalled.
*
*
* @link http://hearingvoices.com/tools/
* @since 0.1.0
*
* @package Postscript
*/
// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/**
* Register taxonomies (to get and delete its terms).
*
* Plugin not activated so tax registration no longer exists.
*
* @since 0.4.7
*/
register_taxonomy( 'postscripts', null );
register_taxonomy( 'poststyles', null );
/**
* Remove plugin taxonomy terms, then remove taxonomy.
*
* @since 0.1.0
*/
if ( function_exists( 'wp_delete_term' ) ) {
global $wp_taxonomies;
$tax_scripts = 'postscripts';
$tax_styles = 'poststyles';
$args_tax = array(
'hide_empty' => 0,
'get' => 'all',
'fields' => 'ids',
);
if ( function_exists( 'taxonomy_exists' ) && taxonomy_exists( $tax_scripts ) ) {
$terms = get_terms( $tax_scripts, $args_tax );
if ( $terms ) {
foreach ( $terms as $term ) {
wp_delete_term( $term, $tax_scripts );
}
}
unset( $wp_taxonomies[ $tax_scripts ] );
}
if ( function_exists( 'taxonomy_exists' ) && taxonomy_exists( $tax_styles ) ) {
$terms = get_terms( $tax_styles, $args_tax );
if ( $terms ) {
foreach ( $terms as $term ) {
wp_delete_term( $term, $tax_styles );
}
}
unset( $wp_taxonomies[ $tax_styles ] );
}
}
/**
* Removes plugin post meta.
*
* @since 0.1.0
*/
if ( function_exists( 'delete_post_meta_by_key' ) ) {
delete_post_meta_by_key ( 'postscript_meta' );
}
/**
* Removes plugin option from database.
*
* @since 0.1.0
*/
if ( function_exists( 'delete_option' ) ) {
delete_option( 'postscript' );
}