Changeset 20525 for trunk/wp-admin/plugins.php
- Timestamp:
- 04/19/2012 03:41:29 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/plugins.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugins.php
r19684 r20525 13 13 $menu_perms = get_site_option( 'menu_items', array() ); 14 14 15 if ( empty( $menu_perms['plugins'] ) && ! is_super_admin() )15 if ( empty( $menu_perms['plugins'] ) && ! current_user_can( 'manage_network_plugins' ) ) 16 16 wp_die( __( 'Cheatin’ uh?' ) ); 17 17 } … … 32 32 33 33 if ( $action ) { 34 $network_wide = false;35 if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )36 $network_wide = true;37 34 38 35 switch ( $action ) { … … 43 40 check_admin_referer('activate-plugin_' . $plugin); 44 41 45 $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), $network_wide);42 $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), is_network_admin() ); 46 43 if ( is_wp_error( $result ) ) { 47 44 if ( 'unexpected_output' == $result->get_error_code() ) { … … 54 51 } 55 52 56 $recent = (array)get_option('recently_activated'); 57 if ( isset($recent[ $plugin ]) ) { 58 unset($recent[ $plugin ]); 59 update_option('recently_activated', $recent); 60 } 53 if ( ! is_network_admin() ) { 54 $recent = (array) get_option( 'recently_activated' ); 55 unset( $recent[ $plugin ] ); 56 update_option( 'recently_activated', $recent ); 57 } 58 61 59 if ( isset($_GET['from']) && 'import' == $_GET['from'] ) { 62 60 wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix … … 67 65 break; 68 66 case 'activate-selected': 69 case 'network-activate-selected':70 67 if ( ! current_user_can('activate_plugins') ) 71 68 wp_die(__('You do not have sufficient permissions to activate plugins for this site.')); … … 76 73 77 74 // Only activate plugins which are not already active. 78 $check = $network_wide? 'is_plugin_active_for_network' : 'is_plugin_active';75 $check = is_network_admin() ? 'is_plugin_active_for_network' : 'is_plugin_active'; 79 76 foreach ( $plugins as $i => $plugin ) 80 77 if ( $check( $plugin ) ) … … 86 83 } 87 84 88 activate_plugins($plugins, self_admin_url('plugins.php?error=true'), $network_wide);89 90 $recent = (array)get_option('recently_activated');91 foreach ( $plugins as $plugin => $time)92 if ( isset($recent[ $plugin ]))93 unset( $recent[ $plugin ]);94 95 update_option('recently_activated', $recent);85 activate_plugins($plugins, self_admin_url('plugins.php?error=true'), is_network_admin() ); 86 87 if ( ! is_network_admin() ) { 88 $recent = (array) get_option('recently_activated' ); 89 foreach ( $plugins as $plugin ) 90 unset( $recent[ $plugin ] ); 91 update_option( 'recently_activated', $recent ); 92 } 96 93 97 94 wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") ); … … 154 151 155 152 check_admin_referer('deactivate-plugin_' . $plugin); 156 deactivate_plugins($plugin); 157 update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); 153 154 if ( ! is_network_admin() && is_plugin_active_for_network() ) { 155 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); 156 exit; 157 } 158 159 deactivate_plugins( $plugin, false, is_network_admin() ); 160 if ( ! is_network_admin() ) 161 update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) ); 158 162 if ( headers_sent() ) 159 163 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />"; … … 169 173 170 174 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 171 $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated. 175 // Do not deactivate plugins which are already deactivated. 176 if ( is_network_admin() ) { 177 $plugins = array_filter( $plugins, 'is_plugin_active_for_network' ); 178 } else { 179 $plugins = array_filter( $plugins, 'is_plugin_active' ); 180 $plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) ); 181 } 172 182 if ( empty($plugins) ) { 173 183 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); … … 175 185 } 176 186 177 deactivate_plugins($plugins); 178 179 $deactivated = array(); 180 foreach ( $plugins as $plugin ) 181 $deactivated[ $plugin ] = time(); 182 183 update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); 187 deactivate_plugins( $plugins, false, is_network_admin() ); 188 189 if ( ! is_network_admin() ) { 190 $deactivated = array(); 191 foreach ( $plugins as $plugin ) 192 $deactivated[ $plugin ] = time(); 193 update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) ); 194 } 195 184 196 wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") ); 185 197 exit; … … 306 318 break; 307 319 case 'clear-recent-list': 308 update_option('recently_activated', array()); 320 if ( ! is_network_admin() ) 321 update_option( 'recently_activated', array() ); 309 322 break; 310 323 }
Note: See TracChangeset
for help on using the changeset viewer.