forked from flowplayer/wordpress-flowplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
62 lines (52 loc) · 1.15 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
<?php
/**
* Flowplayer 5 for WordPress
*
* @package Flowplayer 5 for WordPress
* @author Ulrich Pogson <ulrich@pogson.ch>
* @license GPL-2.0+
* @link https://flowplayer.org/
* @copyright 2013 Flowplayer Ltd
*/
// If uninstall not called from WordPress exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit();
}
/**
* Delete all plugin data
*
* @since 1.0.0
*/
function flowplayer5_delete_data() {
// Delete All the Custom Post Types.
$fp5_post_types = array( 'flowplayer5' );
foreach ( $fp5_post_types as $post_type ) {
$items = get_posts(
array(
'post_type' => $post_type,
'numberposts' => -1,
'fields' => 'ids',
)
);
if ( $items ) {
foreach ( $items as $item ) {
wp_delete_post( $item, true );
}
}
}
// Delete all the Plugin Options.
delete_option( 'fp5_settings_general' );
}
if ( is_multisite() ) {
global $wpdb;
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
if ( $blogs ) {
foreach ( $blogs as $blog ) {
switch_to_blog( $blog['blog_id'] );
flowplayer5_delete_data();
}
restore_current_blog();
}
} else {
flowplayer5_delete_data();
}