PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 2.0.13
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v2.0.13
5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 5.5.43 All 159 releases
wp-data-access / uninstall.php

uninstall.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 2.0.13, at uninstall.php

117 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Fired when the plugin is uninstalled.
4 *
5 * Uninstallation steps:
6 * + Check if plugin is called correcly
7 * + Check if user has the appropriate rights
8 * + Drop plugin tables (unless settings indicate not to)
9 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
10 *
11 * For multisite installation steps 3 and 4 are performed for every blog.
12 *
13 * @package plugin
14 * @author Peter Schulz
15 * @since 1.0.0
16 */
17
18 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
19 exit();
20 }
21
22 if ( ! current_user_can( 'activate_plugins' ) ) {
23 exit();
24 }
25
26 /**
27 * Uninstall blog
28 *
29 * This functions is called when the plugin is uninstalled. The following actions are performed:
30 * + Drop plugin tables (unless settings indicate not to)
31 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
32 *
33 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
34 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
35 *
36 * @author Peter Schulz
37 * @since 1.0.0
38 */
39 function wpda_uninstall_blog() {
40
41 global $wpdb;
42
43 $drop_tables = get_option( 'wpda_uninstall_tables' );
44 if ( ! $drop_tables || 'on' === $drop_tables ) {
45 // Drop repository.
46 $wpdb->query(
47 "
48 DROP TABLE IF EXISTS
49 {$wpdb->prefix}wpda_logging
50 "
51 ); // WPCS: unprepared SQL OK; db call ok; no-cache ok.
52 $wpdb->query(
53 "
54 DROP TABLE IF EXISTS
55 {$wpdb->prefix}wpda_menu_items
56 "
57 ); // WPCS: unprepared SQL OK; db call ok; no-cache ok.
58 $wpdb->query(
59 "
60 DROP TABLE IF EXISTS
61 {$wpdb->prefix}wpda_table_design
62 "
63 ); // WPCS: unprepared SQL OK; db call ok; no-cache ok.
64 $wpdb->query(
65 "
66 DROP TABLE IF EXISTS
67 {$wpdb->prefix}wpdp_project
68 "
69 ); // WPCS: unprepared SQL OK; db call ok; no-cache ok.
70 $wpdb->query(
71 "
72 DROP TABLE IF EXISTS
73 {$wpdb->prefix}wpdp_page
74 "
75 ); // WPCS: unprepared SQL OK; db call ok; no-cache ok.
76 $wpdb->query(
77 "
78 DROP TABLE IF EXISTS
79 {$wpdb->prefix}wpdp_table
80 "
81 ); // WPCS: unprepared SQL OK; db call ok; no-cache ok.
82 }
83
84 $delete_options = get_option( 'wpda_uninstall_options' );
85 if ( ! $delete_options || 'on' === $delete_options ) {
86 // Delete all options from wp_options.
87 $wpdb->query(
88 "
89 DELETE FROM {$wpdb->options}
90 WHERE option_name LIKE 'wpda_%'
91 "
92 ); // db call ok; no-cache ok.
93 }
94
95 }
96
97 if ( is_multisite() ) {
98
99 global $wpdb;
100
101 // Uninstall plugin for alll blogs one by one (will fail silently for blogs having no plugin tables/options).
102 $blogids = $wpdb->get_col( "select blog_id from $wpdb->blogs" ); // db call ok; no-cache ok.
103 foreach ( $blogids as $blog_id ) {
104
105 // Uninstall blog.
106 switch_to_blog( $blog_id );
107 wpda_uninstall_blog();
108 restore_current_blog();
109
110 }
111 } else {
112
113 // Uninstall on single site installation.
114 wpda_uninstall_blog();
115
116 }
117