okt_type=product' ) ); exit(); } if ( 'product' === $route['page'] ) { wp_safe_redirect( admin_url( 'post.php?post=' . $route['product_id'] . '&action=edit' ) ); exit(); } } /** * Get the parsed WooCommerce Admin path. */ protected function get_parsed_route(): array { if ( ! \Automattic\WooCommerce\Admin\PageController::is_admin_page() || ! isset( $_GET['path'] ) ) { return array( 'page' => null, 'product_id' => null, ); } $path = esc_url_raw( wp_unslash( $_GET['path'] ) ); $path_pieces = explode( '/', wp_parse_url( $path, PHP_URL_PATH ) ); return array( 'page' => $path_pieces[1], 'product_id' => 'product' === $path_pieces[1] ? absint( $path_pieces[2] ) : null, ); } /** * Redirect non supported product types to legacy editor. */ public function redirect_non_supported_product_types(): void { $route = $this->get_parsed_route(); $product_id = $route['product_id']; if ( 'product' === $route['page'] && ! $this->is_product_supported( $product_id ) ) { wp_safe_redirect( admin_url( 'post.php?post=' . $route['product_id'] . '&action=edit' ) ); exit(); } } }