PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.2.7
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.2.7
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | uninstall.php +52 -18 2.0.62.2.7 View file →
@@ -1,26 +1,29 @@
1 1 <?php
2 2
3 - // if uninstall.php is not called by WordPress, die
4 - if( !defined('WP_UNINSTALL_PLUGIN') ) {
5 - die;
6 - }
3 +// if uninstall.php is not called by WordPress, die
4 +if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
5 + die;
6 +}
7 +// @formatter:off
8 +function winp_uninstall() {
9 + global $wpdb;
7 10
8 - global $wpdb;
11 + $post_type = 'wbcr-snippets';
12 + $taxonomy = 'wbcr-snippet-tags';
9 13
10 - $snippets = get_posts(array(
11 - 'post_type' => 'wbcr-snippets',
12 - 'post_status' => 'any',
13 - 'numberposts' => -1
14 - ));
14 + $snippets = get_posts( array(
15 + 'post_type' => $post_type,
16 + 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
17 + 'numberposts' => - 1
18 + ) );
15 19
16 - if( !empty($snippets) ) {
17 - foreach((array)$snippets as $snippet) {
18 - wp_delete_post($snippet->ID, true);
20 + if ( ! empty( $snippets ) ) {
21 + foreach ( (array) $snippets as $snippet ) {
22 + wp_delete_post( $snippet->ID, true );
19 23 }
20 24 }
21 25
22 - $taxonomy = 'wbcr-snippet-tags';
23 26 $query = 'SELECT t.name, t.term_id
24 27 FROM ' . $wpdb->terms . ' AS t
25 28 INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt
26 29 ON t.term_id = tt.term_id
@@ -25,12 +28,43 @@
25 28 INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt
26 29 ON t.term_id = tt.term_id
27 30 WHERE tt.taxonomy = "' . $taxonomy . '"';
28 31
29 - $terms = $wpdb->get_results($query);
32 + $terms = $wpdb->get_results( $query );
33 + if ( ! empty( $terms ) ) {
34 + if ( ! taxonomy_exists( $taxonomy ) ) {
35 + register_taxonomy( $taxonomy, $post_type, array() );
36 + }
37 + foreach ( $terms as $term ) {
38 + wp_delete_term( $term->term_id, $taxonomy );
39 + }
30 40
31 - foreach($terms as $term) {
32 - wp_delete_term($term->term_id, $taxonomy);
41 + unregister_taxonomy( $taxonomy );
33 42 }
34 43
35 44 // remove plugin options
36 - $wpdb->query("DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE 'wbcr_inp_%';");
45 + $wpdb->query( "DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE 'wbcr_inp_%';" );
46 +}
47 +
48 +if ( is_multisite() ) {
49 + global $wpdb, $wp_version;
50 +
51 + $wpdb->query( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key LIKE 'wbcr_inp_%';" );
52 +
53 + $blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
54 +
55 + if ( ! empty( $blogs ) ) {
56 + foreach ( $blogs as $id ) {
57 + switch_to_blog( $id );
58 +
59 + winp_uninstall();
60 +
61 + restore_current_blog();
62 + }
63 + }
64 +} else {
65 + if ( get_option( 'wbcr_inp_complete_uninstall', true ) ) {
66 + winp_uninstall();
67 + }
68 +}
69 +// @formatter:on
70 +