Ticket #14915: 15671.diff
| File 15671.diff, 3.4 KB (added by , 15 years ago) |
|---|
-
wp-admin/includes/plugin.php
463 463 * @param bool $network_wide Whether to enable the plugin for all sites in the network or just the current site. Multisite only. Default is false. 464 464 * @return WP_Error|null WP_Error on invalid file or null on success. 465 465 */ 466 function activate_plugin( $plugin, $redirect = '', $network_wide = false ) {466 function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { 467 467 $plugin = plugin_basename( trim( $plugin ) ); 468 468 469 469 if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) { … … 482 482 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error 483 483 ob_start(); 484 484 include(WP_PLUGIN_DIR . '/' . $plugin); 485 do_action( 'activate_plugin', trim( $plugin) ); 485 // Silent mode is used by plugin updater to safely de/reactivate 486 // an active plugin without rerunning activation hooks 487 if ( ! $silent ) 488 do_action( 'activate_plugin', trim( $plugin) ); 486 489 if ( $network_wide ) { 487 490 $current[$plugin] = time(); 488 491 update_site_option( 'active_sitewide_plugins', $current ); … … 491 494 sort($current); 492 495 update_option('active_plugins', $current); 493 496 } 494 do_action( 'activate_' . trim( $plugin ) ); 495 do_action( 'activated_plugin', trim( $plugin) ); 497 if ( ! $silent ) { 498 do_action( 'activate_' . trim( $plugin ) ); 499 do_action( 'activated_plugin', trim( $plugin ) ); 500 } 496 501 if ( ob_get_length() > 0 ) { 497 502 $output = ob_get_clean(); 498 503 return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output); … … 568 573 * @param bool $network_wide Whether to enable the plugin for all sites in the network. 569 574 * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. 570 575 */ 571 function activate_plugins( $plugins, $redirect = '', $network_wide) {576 function activate_plugins( $plugins, $redirect = '', $network_wide, $silent = false ) { 572 577 if ( !is_array($plugins) ) 573 578 $plugins = array($plugins); 574 579 575 580 $errors = array(); 576 foreach ( (array)$plugins as $plugin ) {581 foreach ( $plugins as $plugin ) { 577 582 if ( !empty($redirect) ) 578 583 $redirect = add_query_arg('plugin', $plugin, $redirect); 579 $result = activate_plugin($plugin, $redirect, $network_wide );584 $result = activate_plugin($plugin, $redirect, $network_wide, $silent); 580 585 if ( is_wp_error($result) ) 581 586 $errors[$plugin] = $result; 582 587 } -
wp-admin/update.php
69 69 check_admin_referer('activate-plugin_' . $plugin); 70 70 if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { 71 71 wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); 72 activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ) );72 activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true ); 73 73 wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); 74 74 die(); 75 75 }