WC_WCCOM_Site_Installation_Step_Move_Product::run()publicWC 1.0

Run the step installation process.

Метод класса: WC_WCCOM_Site_Installation_Step_Move_Product{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$WC_WCCOM_Site_Installation_Step_Move_Product = new WC_WCCOM_Site_Installation_Step_Move_Product();
$WC_WCCOM_Site_Installation_Step_Move_Product->run();

Код WC_WCCOM_Site_Installation_Step_Move_Product::run() WC 9.4.2

public function run() {
	$upgrader = WC_WCCOM_Site_Installer::get_wp_upgrader();

	$destination = 'plugin' === $this->state->get_product_type()
		? WP_PLUGIN_DIR
		: get_theme_root();

	$package = array(
		'source'        => $this->state->get_unpacked_path(),
		'destination'   => $destination,
		'clear_working' => true,
		'hook_extra'    => array(
			'type'   => $this->state->get_product_type(),
			'action' => 'install',
		),
	);

	$result = $upgrader->install_package( $package );

	/**
	 * If install package returns error 'folder_exists' treat as success.
	 */
	if ( is_wp_error( $result ) && array_key_exists( 'folder_exists', $result->errors ) ) {
		$existing_folder_path = $result->error_data['folder_exists'];
		$plugin_info          = WC_WCCOM_Site_Installer::get_plugin_info( $existing_folder_path );

		$this->state->set_installed_path( $existing_folder_path );
		$this->state->set_already_installed_plugin_info( $plugin_info );

		return $this->state;
	}

	$this->state->set_installed_path( $result['destination'] );

	return $this->state;
}