-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
30 lines (27 loc) · 774 Bytes
/
uninstall.php
File metadata and controls
30 lines (27 loc) · 774 Bytes
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
<?php
// If uninstall not called from WordPress, exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Delete all portfolio posts and their meta
$portfolios = get_posts([
'post_type' => 'portfolio',
'numberposts' => -1,
'post_status' => 'any',
'fields' => 'ids',
]);
foreach ( $portfolios as $portfolio_id ) {
// Delete post and all associated meta
wp_delete_post( $portfolio_id, true );
}
// Delete portfolio custom taxonomy terms
$terms = get_terms([
'taxonomy' => 'portfolio_category',
'hide_empty' => false,
'fields' => 'ids',
]);
if ( ! is_wp_error( $terms ) ) {
foreach ( $terms as $term_id ) {
wp_delete_term( $term_id, 'portfolio_category' );
}
}