Theme_Upgrader::current_after()publicWP 2.8.0

Turns off maintenance mode after upgrading the active theme.

Hooked to the upgrader_post_install filter by Theme_Upgrader::upgrade() and Theme_Upgrader::bulk_upgrade().

Method of the class: Theme_Upgrader{}

No Hooks.

Return

true|false|WP_Error. The original $response parameter or WP_Error.

Usage

$Theme_Upgrader = new Theme_Upgrader();
$Theme_Upgrader->current_after( $response, $theme );
$response(true|false|WP_Error) (required)
The installation response after the installation has finished.
$theme(array) (required)
Theme arguments.

Changelog

Since 2.8.0 Introduced.

Theme_Upgrader::current_after() code WP 6.6.2

public function current_after( $response, $theme ) {
	if ( is_wp_error( $response ) ) {
		return $response;
	}

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

	// Only run if active theme.
	if ( get_stylesheet() !== $theme ) {
		return $response;
	}

	// Ensure stylesheet name hasn't changed after the upgrade:
	if ( get_stylesheet() === $theme && $theme !== $this->result['destination_name'] ) {
		wp_clean_themes_cache();
		$stylesheet = $this->result['destination_name'];
		switch_theme( $stylesheet );
	}

	// Time to remove maintenance mode. Bulk edit handles this separately.
	if ( ! $this->bulk ) {
		$this->maintenance_mode( false );
	}
	return $response;
}