Plugin Directory

Changeset 3843542


Ignore:
Timestamp:
12/03/2026 11:16:20 PM (less than one hour ago)
Author:
mikeywazowski
Message:

Foundry Helper 5.0.2: reactivate plugins after update.

Location:
foundry-helper
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • foundry-helper/tags/5.0.2/foundry-helper.php

    r3843470 r3843542  
    1212 * Plugin URI:        https://wpfoundry.app
    1313 * Description:       Manage this site from WP Foundry: plugins, themes, users, core updates, and backups.
    14  * Version:           5.0.1
     14 * Version:           5.0.2
    1515 * Requires at least: 6.0
    1616 * Requires PHP:      7.4
    … …  
    3232
    3333define( 'WPFOUNDRY_HELPER_LOADED', true );
    34 define( 'WPFOUNDRY_HELPER_VERSION', '5.0.1' );
     34define( 'WPFOUNDRY_HELPER_VERSION', '5.0.2' );
    3535define( 'WPFOUNDRY_HELPER_FILE', __FILE__ );
    3636define( 'WPFOUNDRY_HELPER_DIR', plugin_dir_path( __FILE__ ) );
  • foundry-helper/tags/5.0.2/includes/actions.php

    r3843470 r3843542  
    254254                return $file;
    255255        }
     256
     257        // Plugin_Upgrader::upgrade() silently deactivates active plugins before
     258        // replacing files. Automatic_Upgrader_Skin does not reactivate them (the
     259        // wp-admin skin does via an iframe). Track state and restore it ourselves.
     260        $was_active         = is_plugin_active( $file );
     261        $was_network_active = is_multisite() && is_plugin_active_for_network( $file );
     262
    256263        wpfoundry_load_upgrader();
    257264        wp_update_plugins();
    … …  
    259266        $upgrader = new Plugin_Upgrader( $skin );
    260267        $result   = $upgrader->upgrade( $file );
     268
     269        $new_file = $upgrader->plugin_info();
     270        if ( is_string( $new_file ) && $new_file !== '' ) {
     271                $file = $new_file;
     272        }
     273
     274        if ( is_wp_error( $result ) || true !== $result ) {
     275                wpfoundry_reactivate_plugin_after_update( $file, $was_active, $was_network_active );
     276                if ( is_wp_error( $result ) ) {
     277                        return $result;
     278                }
     279                return new WP_Error( 'plugin_update_failed', 'Plugin update failed' );
     280        }
     281
     282        $reactivate = wpfoundry_reactivate_plugin_after_update( $file, $was_active, $was_network_active );
     283        if ( is_wp_error( $reactivate ) ) {
     284                return new WP_Error(
     285                        'plugin_reactivate_failed',
     286                        sprintf(
     287                                /* translators: %s: activation error message */
     288                                'Plugin updated but could not be reactivated: %s',
     289                                $reactivate->get_error_message()
     290                        )
     291                );
     292        }
     293
     294        return array(
     295                'plugin'    => $file,
     296                'updated'   => true,
     297                'active'    => is_plugin_active( $file ),
     298                'reactivated' => (bool) $was_active,
     299        );
     300}
     301
     302/**
     303 * Reactivate a plugin that WordPress deactivated during an upgrade.
     304 *
     305 * @param string $file               Plugin basename.
     306 * @param bool   $was_active         Whether it was active before the update.
     307 * @param bool   $was_network_active Whether it was network-active before the update.
     308 * @return true|WP_Error True on success / nothing to do, WP_Error on activation failure.
     309 */
     310function wpfoundry_reactivate_plugin_after_update( $file, $was_active, $was_network_active ) {
     311        if ( ! $was_active ) {
     312                return true;
     313        }
     314        if ( ! function_exists( 'activate_plugin' ) ) {
     315                require_once ABSPATH . 'wp-admin/includes/plugin.php';
     316        }
     317        if ( is_plugin_active( $file ) ) {
     318                return true;
     319        }
     320        $result = activate_plugin( $file, '', (bool) $was_network_active, true );
    261321        if ( is_wp_error( $result ) ) {
    262322                return $result;
    263323        }
    264         if ( $result !== true ) {
    265                 return new WP_Error( 'plugin_update_failed', 'Plugin update failed' );
    266         }
    267         return array( 'plugin' => $file, 'updated' => true );
     324        return true;
    268325}
    269326
  • foundry-helper/tags/5.0.2/readme.txt

    r3843470 r3843542  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 5.0.1
     7Stable tag: 5.0.2
    88License: GPL-2.0-or-later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5252== Changelog ==
    5353
     54= 5.0.2 =
     55* Reactivate plugins after update. WordPress deactivates them during the upgrade and Automatic_Upgrader_Skin does not turn them back on.
     56
    5457= 5.0.1 =
    5558* Database and other backup downloads keep their token on disk, so a site with an object cache can still download the file.
  • foundry-helper/trunk/foundry-helper.php

    r3843470 r3843542  
    1212 * Plugin URI:        https://wpfoundry.app
    1313 * Description:       Manage this site from WP Foundry: plugins, themes, users, core updates, and backups.
    14  * Version:           5.0.1
     14 * Version:           5.0.2
    1515 * Requires at least: 6.0
    1616 * Requires PHP:      7.4
    … …  
    3232
    3333define( 'WPFOUNDRY_HELPER_LOADED', true );
    34 define( 'WPFOUNDRY_HELPER_VERSION', '5.0.1' );
     34define( 'WPFOUNDRY_HELPER_VERSION', '5.0.2' );
    3535define( 'WPFOUNDRY_HELPER_FILE', __FILE__ );
    3636define( 'WPFOUNDRY_HELPER_DIR', plugin_dir_path( __FILE__ ) );
  • foundry-helper/trunk/includes/actions.php

    r3843470 r3843542  
    254254                return $file;
    255255        }
     256
     257        // Plugin_Upgrader::upgrade() silently deactivates active plugins before
     258        // replacing files. Automatic_Upgrader_Skin does not reactivate them (the
     259        // wp-admin skin does via an iframe). Track state and restore it ourselves.
     260        $was_active         = is_plugin_active( $file );
     261        $was_network_active = is_multisite() && is_plugin_active_for_network( $file );
     262
    256263        wpfoundry_load_upgrader();
    257264        wp_update_plugins();
    … …  
    259266        $upgrader = new Plugin_Upgrader( $skin );
    260267        $result   = $upgrader->upgrade( $file );
     268
     269        $new_file = $upgrader->plugin_info();
     270        if ( is_string( $new_file ) && $new_file !== '' ) {
     271                $file = $new_file;
     272        }
     273
     274        if ( is_wp_error( $result ) || true !== $result ) {
     275                wpfoundry_reactivate_plugin_after_update( $file, $was_active, $was_network_active );
     276                if ( is_wp_error( $result ) ) {
     277                        return $result;
     278                }
     279                return new WP_Error( 'plugin_update_failed', 'Plugin update failed' );
     280        }
     281
     282        $reactivate = wpfoundry_reactivate_plugin_after_update( $file, $was_active, $was_network_active );
     283        if ( is_wp_error( $reactivate ) ) {
     284                return new WP_Error(
     285                        'plugin_reactivate_failed',
     286                        sprintf(
     287                                /* translators: %s: activation error message */
     288                                'Plugin updated but could not be reactivated: %s',
     289                                $reactivate->get_error_message()
     290                        )
     291                );
     292        }
     293
     294        return array(
     295                'plugin'    => $file,
     296                'updated'   => true,
     297                'active'    => is_plugin_active( $file ),
     298                'reactivated' => (bool) $was_active,
     299        );
     300}
     301
     302/**
     303 * Reactivate a plugin that WordPress deactivated during an upgrade.
     304 *
     305 * @param string $file               Plugin basename.
     306 * @param bool   $was_active         Whether it was active before the update.
     307 * @param bool   $was_network_active Whether it was network-active before the update.
     308 * @return true|WP_Error True on success / nothing to do, WP_Error on activation failure.
     309 */
     310function wpfoundry_reactivate_plugin_after_update( $file, $was_active, $was_network_active ) {
     311        if ( ! $was_active ) {
     312                return true;
     313        }
     314        if ( ! function_exists( 'activate_plugin' ) ) {
     315                require_once ABSPATH . 'wp-admin/includes/plugin.php';
     316        }
     317        if ( is_plugin_active( $file ) ) {
     318                return true;
     319        }
     320        $result = activate_plugin( $file, '', (bool) $was_network_active, true );
    261321        if ( is_wp_error( $result ) ) {
    262322                return $result;
    263323        }
    264         if ( $result !== true ) {
    265                 return new WP_Error( 'plugin_update_failed', 'Plugin update failed' );
    266         }
    267         return array( 'plugin' => $file, 'updated' => true );
     324        return true;
    268325}
    269326
  • foundry-helper/trunk/readme.txt

    r3843470 r3843542  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 5.0.1
     7Stable tag: 5.0.2
    88License: GPL-2.0-or-later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5252== Changelog ==
    5353
     54= 5.0.2 =
     55* Reactivate plugins after update. WordPress deactivates them during the upgrade and Automatic_Upgrader_Skin does not turn them back on.
     56
    5457= 5.0.1 =
    5558* Database and other backup downloads keep their token on disk, so a site with an object cache can still download the file.
Note: See TracChangeset for help on using the changeset viewer.