Plugin_Upgrader::active_before( bool|WP_Error $return, array $plugin )

Turns on maintenance mode before attempting to background update an active plugin.


Description Description

Hooked to the ‘upgrader_pre_install’ filter by Plugin_Upgrader::upgrade().


Top ↑

Parameters Parameters

$return

(bool|WP_Error) (Required) Upgrade offer return.

$plugin

(array) (Required) Plugin package arguments.


Top ↑

Return Return

(bool|WP_Error) The passed in $return param or WP_Error.



Top ↑

Source Source

File: wp-admin/includes/class-plugin-upgrader.php

	public function active_before( $return, $plugin ) {
		if ( is_wp_error( $return ) ) {
			return $return;
		}

		// Only enable maintenance mode when in cron (background update).
		if ( ! wp_doing_cron() ) {
			return $return;
		}

		$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';

		// Only run if plugin is active.
		if ( ! is_plugin_active( $plugin ) ) {
			return $return;
		}

		// Change to maintenance mode. Bulk edit handles this separately.
		if ( ! $this->bulk ) {
			$this->maintenance_mode( true );
		}

		return $return;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
5.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.