Ticket #4169: auto-deactivate.diff

File auto-deactivate.diff, 824 bytes (added by rob1n, 6 years ago)

Automattically disable Automattic Widgets if it's active

Line 
1Index: wp-admin/upgrade-functions.php
2===================================================================
3--- wp-admin/upgrade-functions.php      (revision 5342)
4+++ wp-admin/upgrade-functions.php      (working copy)
5@@ -188,6 +188,8 @@
6        if ( $wp_current_db_version < 5200 ) {
7                upgrade_230();
8        }
9+       
10+       maybe_disable_automattic_widgets();
11 
12        $wp_rewrite->flush_rules();
13 
14@@ -1111,4 +1113,13 @@
15                die(sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
16 }
17 
18-?>
19+function maybe_disable_automattic_widgets() {
20+       $plugins = __get_option( 'active_plugins' );
21+       
22+       if ( in_array( 'widgets/widgets.php', $plugins ) ) {
23+               array_splice( $plugins, array_search( 'widgets/widgets.php', $plugins ), 1 );
24+               update_option( 'active_plugins', $plugins );
25+       }
26+}
27+
28+?>
29\ No newline at end of file