src/Modules/Rollback.php
private function start_rollback_plugin() {
		$rollback         = $this->get_rollback();
		$plugin_transient = get_site_transient( 'update_plugins' );
		$plugin_folder    = $this->product->get_slug();
		$plugin_file      = $this->product->get_file();
		$version          = $rollback['version'];
		$temp_array       = array(
			'slug'        => $plugin_folder,
			'new_version' => $version,
			'package'     => $rollback['url'],
		);

		$temp_object = (object) $temp_array;
		$plugin_transient->response[ $plugin_folder . '/' . $plugin_file ] = $temp_object;
		set_site_transient( 'update_plugins', $plugin_transient );

		$transient = get_transient( $this->product->get_key() . '_warning_rollback' );

		if ( false === $transient ) {
			set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
			require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
			$title         = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
			$plugin        = $plugin_folder . '/' . $plugin_file;
			$nonce         = 'upgrade-plugin_' . $plugin;
			$url           = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
			$upgrader_skin = new \Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) );
			$upgrader      = new \Plugin_Upgrader( $upgrader_skin );
			$upgrader->upgrade( $plugin );
			delete_transient( $this->product->get_key() . '_warning_rollback' );
			wp_die(
				'',
				$title,
				array(
					'response' => 200,
				)
			);
		}
	}
private function start_rollback_plugin() {
		$rollback         = $this->get_rollback();
		$plugin_transient = get_site_transient( 'update_plugins' );
		$plugin_folder    = $this->product->get_slug();
		$plugin_file      = $this->product->get_file();
		$version          = $rollback['version'];
		$temp_array       = array(
			'slug'        => $plugin_folder,
			'new_version' => $version,
			'package'     => $rollback['url'],
		);

		$temp_object = (object) $temp_array;
		$plugin_transient->response[ $plugin_folder . '/' . $plugin_file ] = $temp_object;
		set_site_transient( 'update_plugins', $plugin_transient );

		$transient = get_transient( $this->product->get_key() . '_warning_rollback' );

		if ( false === $transient ) {
			set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
			require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
			$title         = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
			$plugin        = $plugin_folder . '/' . $plugin_file;
			$nonce         = 'upgrade-plugin_' . $plugin;
			$url           = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
			$upgrader_skin = new \Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) );
			$upgrader      = new \Plugin_Upgrader( $upgrader_skin );
			$upgrader->upgrade( $plugin );
			delete_transient( $this->product->get_key() . '_warning_rollback' );
			wp_die(
				'',
				$title,
				array(
					'response' => 200,
				)
			);
		}
	}
private function start_rollback_plugin ( ) { $ rollback = $ this -> get_rollback ( ) ; $ plugin_transient = get_site_transient ( 'update_plugins' ) ; $ plugin_folder = $ this -> product -> get_slug ( ) ; $ plugin_file = $ this -> product -> get_file ( ) ; $ version = $ rollback [ 'version' ] ; $ temp_array = array ( 'slug' => $ plugin_folder , 'new_version' => $ version , 'package' => $ rollback [ 'url' ] , ) ; $ temp_object = ( object ) $ temp_array ; $ plugin_transient -> response [ $ plugin_folder . '/' . $ plugin_file ] = $ temp_object ; set_site_transient ( 'update_plugins' , $ plugin_transient ) ; $ transient = get_transient ( $ this -> product -> get_key ( ) . '_warning_rollback' ) ; if ( false === $ transient ) { set_transient ( $ this -> product -> get_key ( ) . '_warning_rollback' , 'in progress' , 30 ) ; require_once ( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ) ; $ title = sprintf ( apply_filters ( $ this -> product -> get_key ( ) . '_rollback_message' , 'Rolling back %s to v%s' ) , $ this -> product -> get_name ( ) , $ version ) ; $ plugin = $ plugin_folder . '/' . $ plugin_file ; $ nonce = 'upgrade-plugin_' . $ plugin ; $ url = 'update.php?action=upgrade-plugin&plugin=' . urlencode ( $ plugin ) ; $ upgrader_skin = new \ Plugin_Upgrader_Skin ( compact ( 'title' , 'nonce' , 'url' , 'plugin' ) ) ; $ upgrader = new \ Plugin_Upgrader ( $ upgrader_skin ) ; $ upgrader -> upgrade ( $ plugin ) ; delete_transient ( $ this -> product -> get_key ( ) . '_warning_rollback' ) ; wp_die ( '' , $ title , array ( 'response' => 200 , ) ) ; } }
Start the rollback operation for the plugin.
Start the rollback operation for the plugin .