Make WordPress Core

Changeset 16012


Ignore:
Timestamp:
10/27/2010 01:40:14 PM (14 years ago)
Author:
scribu
Message:

Don't call activation hooks when upgrading. Props joelhardi for initial patch. See #14915

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r16011 r16012  
    461461 * @param string $plugin Plugin path to main plugin file with plugin data.
    462462 * @param string $redirect Optional. URL to redirect to.
    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.
     463 * @param bool $network_wide Whether to enable the plugin for all sites in the
     464 *   network or just the current site. Multisite only. Default is false.
     465 * @param bool $silent Prevent calling activation hooks. Optional, default is false.
    464466 * @return WP_Error|null WP_Error on invalid file or null on success.
    465467 */
    466 function activate_plugin( $plugin, $redirect = '', $network_wide = false) {
     468function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
    467469    $plugin = plugin_basename( trim( $plugin ) );
    468470
     
    483485        ob_start();
    484486        include(WP_PLUGIN_DIR . '/' . $plugin);
    485         do_action( 'activate_plugin', $plugin, $network_wide );
    486         do_action( 'activate_' . $plugin, $network_wide );
     487
     488        if ( ! $silent ) {
     489            do_action( 'activate_plugin', $plugin, $network_wide );
     490            do_action( 'activate_' . $plugin, $network_wide );
     491        }
     492
    487493        if ( $network_wide ) {
    488494            $current[$plugin] = time();
     
    493499            update_option('active_plugins', $current);
    494500        }
    495         do_action( 'activated_plugin', $plugin, $network_wide );
     501
     502        if ( ! $silent ) {
     503            do_action( 'activated_plugin', $plugin, $network_wide );
     504        }
     505
    496506        if ( ob_get_length() > 0 ) {
    497507            $output = ob_get_clean();
     
    513523 *
    514524 * @param string|array $plugins Single plugin or list of plugins to deactivate.
    515  * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
     525 * @param bool $silent Prevent calling deactivation hooks. Default is false.
    516526 */
    517527function deactivate_plugins( $plugins, $silent = false ) {
     
    567577 * @param string $redirect Redirect to page after successful activation.
    568578 * @param bool $network_wide Whether to enable the plugin for all sites in the network.
     579 * @param bool $silent Prevent calling activation hooks. Default is false.
    569580 * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
    570581 */
    571 function activate_plugins($plugins, $redirect = '', $network_wide) {
     582function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
    572583    if ( !is_array($plugins) )
    573584        $plugins = array($plugins);
    574585
    575586    $errors = array();
    576     foreach ( (array) $plugins as $plugin ) {
     587    foreach ( $plugins as $plugin ) {
    577588        if ( !empty($redirect) )
    578589            $redirect = add_query_arg('plugin', $plugin, $redirect);
    579         $result = activate_plugin($plugin, $redirect, $network_wide);
     590        $result = activate_plugin($plugin, $redirect, $network_wide, $silent);
    580591        if ( is_wp_error($result) )
    581592            $errors[$plugin] = $result;
  • trunk/wp-admin/update.php

    r16008 r16012  
    7272        if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
    7373            wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
    74             activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ) );
     74            activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
    7575            wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
    7676            die();
Note: See TracChangeset for help on using the changeset viewer.