| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | |
| 4 | 4 | class Uninstall { |
| 5 | 5 | /** |
| 6 | 6 | * Hold Plugin class |
| 7 | + * | |
| 7 | 8 | * @var Plugin |
| 8 | 9 | */ |
| 9 | 10 | public $plugin; |
| 10 | 11 | |
| @@ -21,9 +22,9 @@ | ||
| 21 | 22 | * @var array |
| 22 | 23 | */ |
| 23 | 24 | public $user_meta; |
| 24 | 25 | |
| 25 | - function __construct( $plugin ) { | |
| 26 | + public function __construct( $plugin ) { | |
| 26 | 27 | $this->plugin = $plugin; |
| 27 | 28 | |
| 28 | 29 | $this->user_meta = array( |
| 29 | 30 | 'edit_stream_per_page', |
| @@ -36,10 +37,8 @@ | ||
| 36 | 37 | /** |
| 37 | 38 | * Uninstall Stream by deleting its data |
| 38 | 39 | */ |
| 39 | 40 | public function uninstall() { |
| 40 | - //check_ajax_referer( 'stream_nonce', 'wp_stream_nonce' ); | |
| 41 | - | |
| 42 | 41 | $this->options = array( |
| 43 | 42 | $this->plugin->install->option_key, |
| 44 | 43 | $this->plugin->settings->option_key, |
| 45 | 44 | $this->plugin->settings->network_options_key, |
| @@ -51,8 +50,14 @@ | ||
| 51 | 50 | esc_html__( "You don't have sufficient privileges to do this action.", 'stream' ) |
| 52 | 51 | ); |
| 53 | 52 | } |
| 54 | 53 | |
| 54 | + if ( defined( 'DISALLOW_FILE_MODS' ) && true === DISALLOW_FILE_MODS ) { | |
| 55 | + wp_die( | |
| 56 | + esc_html__( "You don't have sufficient file permissions to do this action.", 'stream' ) | |
| 57 | + ); | |
| 58 | + } | |
| 59 | + | |
| 55 | 60 | // Prevent this action from firing |
| 56 | 61 | remove_action( 'deactivate_plugin', array( 'Connector_Installer', 'callback' ), null ); |
| 57 | 62 | |
| 58 | 63 | // Just in case |
| @@ -61,9 +66,9 @@ | ||
| 61 | 66 | } |
| 62 | 67 | |
| 63 | 68 | // Drop everything on single site installs or when network activated |
| 64 | 69 | // Otherwise only delete data relative to the current blog |
| 65 | - if ( ! is_multisite() || is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) { | |
| 70 | + if ( ! is_multisite() || $this->plugin->is_network_activated() ) { | |
| 66 | 71 | $this->delete_all_records(); |
| 67 | 72 | $this->delete_all_options(); |
| 68 | 73 | $this->delete_all_user_meta(); |
| 69 | 74 | } else { |
| @@ -135,10 +140,10 @@ | ||
| 135 | 140 | // Wildcard matches on network options |
| 136 | 141 | $wpdb->query( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key LIKE '%wp_stream%';" ); |
| 137 | 142 | |
| 138 | 143 | // Delete options from each blog on network |
| 139 | - foreach ( wp_get_sites() as $blog ) { | |
| 140 | - $this->delete_blog_options( absint( $blog['blog_id'] ) ); | |
| 144 | + foreach ( wp_stream_get_sites() as $blog ) { | |
| 145 | + $this->delete_blog_options( absint( $blog->blog_id ) ); | |
| 141 | 146 | } |
| 142 | 147 | } |
| 143 | 148 | |
| 144 | 149 | /** |
| @@ -152,12 +157,10 @@ | ||
| 152 | 157 | } |
| 153 | 158 | |
| 154 | 159 | global $wpdb; |
| 155 | 160 | |
| 156 | - $blog_prefix = $wpdb->get_blog_prefix( $blog_id ); | |
| 157 | - | |
| 158 | 161 | // Wildcard matches |
| 159 | - $wpdb->query( "DELETE FROM {$blog_prefix}options WHERE option_name LIKE '%wp_stream%';" ); | |
| 162 | + $wpdb->query( "DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE '%wp_stream%';" ); | |
| 160 | 163 | |
| 161 | 164 | // Specific options |
| 162 | 165 | foreach ( $this->options as $option ) { |
| 163 | 166 | delete_blog_option( $blog_id, $option ); |
| @@ -174,9 +177,11 @@ | ||
| 174 | 177 | $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%wp_stream%';" ); |
| 175 | 178 | |
| 176 | 179 | // Specific user meta |
| 177 | 180 | foreach ( $this->user_meta as $meta_key ) { |
| 178 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$meta_key}';" ); | |
| 181 | + $wpdb->query( | |
| 182 | + $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s;", $meta_key ) | |
| 183 | + ); | |
| 179 | 184 | } |
| 180 | 185 | } |
| 181 | 186 | |
| 182 | 187 | /** |
| @@ -190,16 +195,16 @@ | ||
| 190 | 195 | } |
| 191 | 196 | |
| 192 | 197 | global $wpdb; |
| 193 | 198 | |
| 194 | - $blog_prefix = $wpdb->get_blog_prefix( $blog_id ); | |
| 195 | - | |
| 196 | 199 | // Wildcard matches |
| 197 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '{$blog_prefix}%wp_stream%';" ); | |
| 200 | + $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '{$wpdb->prefix}%wp_stream%';" ); | |
| 198 | 201 | |
| 199 | 202 | // Specific user meta |
| 200 | 203 | foreach ( $this->user_meta as $meta_key ) { |
| 201 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}{$meta_key}';" ); | |
| 204 | + $wpdb->query( | |
| 205 | + $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = {$wpdb->prefix}%s;", $meta_key ) | |
| 206 | + ); | |
| 202 | 207 | } |
| 203 | 208 | } |
| 204 | 209 | |
| 205 | 210 | /** |