WC_WCCOM_Site_Installation_Step_Download_Product{}WC 1.0

WC_WCCOM_Site_Installation_Step_Download_Product class

Хуков нет.

Использование

$WC_WCCOM_Site_Installation_Step_Download_Product = new WC_WCCOM_Site_Installation_Step_Download_Product();
// use class methods

Методы

  1. public __construct( $state )
  2. public run()

Код WC_WCCOM_Site_Installation_Step_Download_Product{} WC 9.8.2

class WC_WCCOM_Site_Installation_Step_Download_Product implements WC_WCCOM_Site_Installation_Step {
	/**
	 * The current installation state.
	 *
	 * @var WC_WCCOM_Site_Installation_State
	 */
	protected $state;

	/**
	 * Constructor.
	 *
	 * @param array $state The current installation state.
	 */
	public function __construct( $state ) {
		$this->state = $state;
	}

	/**
	 * Run the step installation process.
	 *
	 * @throws Installer_Error Installer Error.
	 */
	public function run() {
		$upgrader = WC_WCCOM_Site_Installer::get_wp_upgrader();

		$download_path = $upgrader->download_package( $this->state->get_download_url() );

		if ( is_wp_error( $download_path ) || empty( $download_path ) ) {
			throw new Installer_Error( Installer_Error_Codes::MISSING_DOWNLOAD_PATH );
		}

		$this->state->set_download_path( $download_path );

		return $this->state;
	}
}