Title: Plugin_Upgrader::bulk_upgrade
Published: April 25, 2014
Last modified: August 20, 2026

---

# Plugin_Upgrader::bulk_upgrade( string[] $plugins, array $args = array() ): array|false

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#wp--skip-link--target)

Upgrades several plugins at once.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#parameters)󠁿

 `$plugins`string[]required

Array of paths to plugin files relative to the plugins directory.

`$args`arrayoptional

Other arguments for upgrading several plugins at once.

 * `clear_update_cache` bool
 * Whether to clear the plugin updates cache if successful. Default true.

Default:`array()`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#return)󠁿

 array|false An array of results indexed by plugin file, or false if unable to connect
to the filesystem.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#source)󠁿

    ```php
    public function bulk_upgrade( $plugins, $args = array() ) {
    	$wp_version = wp_get_wp_version();

    	$defaults    = array(
    		'clear_update_cache' => true,
    	);
    	$parsed_args = wp_parse_args( $args, $defaults );

    	$this->init();
    	$this->bulk = true;
    	$this->upgrade_strings();

    	$current = get_site_transient( 'update_plugins' );

    	add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );

    	$this->skin->header();

    	// Connect to the filesystem first.
    	$connected = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
    	if ( ! $connected ) {
    		$this->skin->footer();
    		return false;
    	}

    	$this->skin->bulk_header();

    	/*
    	 * Only start maintenance mode if:
    	 * - running Multisite and there are one or more plugins specified, OR
    	 * - a plugin with an update available is currently active.
    	 * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible.
    	 */
    	$maintenance = ( is_multisite() && ! empty( $plugins ) );
    	foreach ( $plugins as $plugin ) {
    		$maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin ] ) );
    	}
    	if ( $maintenance ) {
    		$this->maintenance_mode( true );
    	}

    	$results = array();

    	$this->update_count   = count( $plugins );
    	$this->update_current = 0;
    	foreach ( $plugins as $plugin ) {
    		++$this->update_current;
    		$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true );

    		if ( ! isset( $current->response[ $plugin ] ) ) {
    			$this->skin->set_result( 'up_to_date' );
    			$this->skin->before();
    			$this->skin->feedback( 'up_to_date' );
    			$this->skin->after();
    			$results[ $plugin ] = true;
    			continue;
    		}

    		// Get the URL to the zip file.
    		$upgrade_data = $current->response[ $plugin ];

    		$this->skin->plugin_active = is_plugin_active( $plugin );

    		if ( isset( $upgrade_data->requires ) && ! is_wp_version_compatible( $upgrade_data->requires ) ) {
    			$result = new WP_Error(
    				'incompatible_wp_required_version',
    				sprintf(
    					/* translators: 1: Current WordPress version, 2: WordPress version required by the new plugin version. */
    					__( 'Your WordPress version is %1$s, however the new plugin version requires %2$s.' ),
    					$wp_version,
    					$upgrade_data->requires
    				)
    			);

    			$this->skin->before( $result );
    			$this->skin->error( $result );
    			$this->skin->after();
    		} elseif ( isset( $upgrade_data->requires_php ) && ! is_php_version_compatible( $upgrade_data->requires_php ) ) {
    			$result = new WP_Error(
    				'incompatible_php_required_version',
    				sprintf(
    					/* translators: 1: Current PHP version, 2: PHP version required by the new plugin version. */
    					__( 'The PHP version on your server is %1$s, however the new plugin version requires %2$s.' ),
    					PHP_VERSION,
    					$upgrade_data->requires_php
    				)
    			);

    			$this->skin->before( $result );
    			$this->skin->error( $result );
    			$this->skin->after();
    		} else {
    			add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
    			$result = $this->run(
    				array(
    					'package'           => $upgrade_data->package,
    					'destination'       => WP_PLUGIN_DIR,
    					'clear_destination' => true,
    					'clear_working'     => true,
    					'is_multi'          => true,
    					'hook_extra'        => array(
    						'plugin'      => $plugin,
    						'temp_backup' => array(
    							'slug' => dirname( $plugin ),
    							'src'  => WP_PLUGIN_DIR,
    							'dir'  => 'plugins',
    						),
    					),
    				)
    			);
    			remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
    		}

    		$results[ $plugin ] = $result;

    		// Prevent credentials auth screen from displaying multiple times.
    		if ( false === $result ) {
    			break;
    		}
    	} // End foreach $plugins.

    	$this->maintenance_mode( false );

    	// Force refresh of plugin update information.
    	wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );

    	/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
    	do_action(
    		'upgrader_process_complete',
    		$this,
    		array(
    			'action'  => 'update',
    			'type'    => 'plugin',
    			'bulk'    => true,
    			'plugins' => $plugins,
    		)
    	);

    	$this->skin->bulk_footer();

    	$this->skin->footer();

    	// Cleanup our hooks, in case something else does an upgrade on this connection.
    	remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );

    	/*
    	 * Ensure any future auto-update failures trigger a failure email by removing
    	 * the last failure notification from the list when plugins update successfully.
    	 */
    	$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );

    	foreach ( $results as $plugin => $result ) {
    		// Maintain last failure notification when plugins failed to update manually.
    		if ( ! $result || is_wp_error( $result ) || ! isset( $past_failure_emails[ $plugin ] ) ) {
    			continue;
    		}

    		unset( $past_failure_emails[ $plugin ] );
    	}

    	update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );

    	return $results;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-plugin-upgrader.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/class-plugin-upgrader.php#L285)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-plugin-upgrader.php#L285-L448)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#hooks)󠁿

 [do_action( ‘upgrader_process_complete’, WP_Upgrader $upgrader, array $hook_extra )](https://developer.wordpress.org/reference/hooks/upgrader_process_complete/)

Fires when the upgrader process is complete.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_wp_version()](https://developer.wordpress.org/reference/functions/wp_get_wp_version/)`wp-includes/functions.php` |

Returns the current WordPress version.

  | 
| [is_wp_version_compatible()](https://developer.wordpress.org/reference/functions/is_wp_version_compatible/)`wp-includes/functions.php` |

Checks compatibility with the current WordPress version.

  | 
| [is_php_version_compatible()](https://developer.wordpress.org/reference/functions/is_php_version_compatible/)`wp-includes/functions.php` |

Checks compatibility with the current PHP version.

  | 
| [Plugin_Upgrader::upgrade_strings()](https://developer.wordpress.org/reference/classes/plugin_upgrader/upgrade_strings/)`wp-admin/includes/class-plugin-upgrader.php` |

Initializes the upgrade strings.

  | 
| [wp_clean_plugins_cache()](https://developer.wordpress.org/reference/functions/wp_clean_plugins_cache/)`wp-admin/includes/plugin.php` |

Clears the plugins cache used by [get_plugins()](https://developer.wordpress.org/reference/functions/get_plugins/) and by default, the plugin updates cache.

  | 
| [is_plugin_active()](https://developer.wordpress.org/reference/functions/is_plugin_active/)`wp-admin/includes/plugin.php` |

Determines whether a plugin is active.

  | 
| [get_plugin_data()](https://developer.wordpress.org/reference/functions/get_plugin_data/)`wp-admin/includes/plugin.php` |

Parses the plugin contents to retrieve plugin’s metadata.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  | 
| [add_filter()](https://developer.wordpress.org/reference/functions/add_filter/)`wp-includes/plugin.php` |

Adds a callback function to a filter hook.

  | 
| [remove_filter()](https://developer.wordpress.org/reference/functions/remove_filter/)`wp-includes/plugin.php` |

Removes a callback function from a filter hook.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [get_site_transient()](https://developer.wordpress.org/reference/functions/get_site_transient/)`wp-includes/option.php` |

Retrieves the value of a site transient.

  | 
| [update_option()](https://developer.wordpress.org/reference/functions/update_option/)`wp-includes/option.php` |

Updates the value of an option that was already added.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 13 more](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/plugin_upgrader/bulk_upgrade/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.7.0](https://developer.wordpress.org/reference/since/3.7.0/) | The `$args` parameter was added, making clearing the plugin update cache optional. | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fplugin_upgrader%2Fbulk_upgrade%2F)
before being able to contribute a note or feedback.