Automattic\WooCommerce\Admin\Features\ProductBlockEditor

RedirectionController::maybe_redirect_to_new_editor()publicWC 1.0

Redirects from old product form to the new product form if the feature product_block_editor is enabled.

Method of the class: RedirectionController{}

No Hooks.

Return

null. Nothing (null).

Usage

$RedirectionController = new RedirectionController();
$RedirectionController->maybe_redirect_to_new_editor(): void;

RedirectionController::maybe_redirect_to_new_editor() code WC 9.7.1

public function maybe_redirect_to_new_editor(): void {
	if ( $this->is_legacy_add_new_screen() ) {
		wp_safe_redirect( admin_url( 'admin.php?page=wc-admin&path=/add-product' ) );
		exit();
	}

	if ( $this->is_legacy_edit_screen() ) {
		$product_id = isset( $_GET['post'] ) ? absint( $_GET['post'] ) : null;
		if ( ! $this->is_product_supported( $product_id ) ) {
			return;
		}
		wp_safe_redirect( admin_url( 'admin.php?page=wc-admin&path=/product/' . $product_id ) );
		exit();
	}
}