PluginProbe
Code Snippets / 2.12.0
Code Snippets v2.12.0
3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 3.0.1 All 64 releases
code-snippets / uninstall.php

uninstall.php in Code Snippets 2.12.0, at uninstall.php

76 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Cleans up data created by this plugin
5 * @package Code_Snippets
6 * @since 2.0
7 */
8
9 /* Ensure this plugin is actually being uninstalled */
10 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
11 exit();
12 }
13
14 /* Fetch the Complete Uninstall option from the database settings */
15 $unified = false;
16 if ( is_multisite() ) {
17 $menu_perms = get_site_option( 'menu_items', array() );
18 $unified = empty( $menu_perms['snippets_settings'] );
19 }
20
21 $settings = $unified ? get_site_option( 'code_snippets_settings' ) : get_option( 'code_snippets_settings' );
22
23 /* Short circuit the uninstall cleanup process if the option is not enabled */
24 if ( ! isset( $settings['general']['complete_uninstall'] ) || ! $settings['general']['complete_uninstall'] ) {
25 return;
26 }
27
28 /**
29 * Clean up data created by this plugin for a single site
30 * @since 2.0
31 */
32 function code_snippets_uninstall_site() {
33 global $wpdb;
34
35 /* Remove snippets database table */
36 $wpdb->query( "DROP TABLE IF EXISTS $wpdb->snippets" );
37
38 /* Remove saved options */
39 delete_option( 'code_snippets_version' );
40 delete_option( 'recently_activated_snippets' );
41 delete_option( 'code_snippets_settings' );
42 }
43
44
45 global $wpdb;
46
47 $wpdb->snippets = $wpdb->prefix . 'snippets';
48 $wpdb->ms_snippets = $wpdb->prefix . 'ms_snippets';
49
50 /* Multisite uninstall */
51
52 if ( is_multisite() ) {
53
54 /* Loop through sites */
55 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
56
57 if ( $blog_ids ) {
58
59 foreach ( $blog_ids as $blog_id ) {
60 switch_to_blog( $blog_id );
61 code_snippets_uninstall_site();
62 }
63
64 restore_current_blog();
65 }
66
67 /* Remove multisite snippets database table */
68 $wpdb->query( "DROP TABLE IF EXISTS $wpdb->ms_snippets" );
69
70 /* Remove saved options */
71 delete_site_option( 'code_snippets_version' );
72 delete_site_option( 'recently_activated_snippets' );
73 } else {
74 code_snippets_uninstall_site();
75 }
76