tely redirect to a given WC Admin path. * Note that this function immediately ends the execution. * * @param string $path The WC Admin path to redirect to * * @return void */ public function redirect_to( $path ): void { // If we are already on this path, do nothing. if ( $this->is_current_wc_admin_page( $path ) ) { return; } $params = [ 'page' => PageController::PAGE_ROOT, 'path' => $path, ]; wp_safe_redirect( admin_url( add_query_arg( $params, 'admin.php' ) ) ); exit(); } /** * Check if the current WC Admin page matches the given path. * * @param string $path The path to check. * * @return bool */ public function is_current_wc_admin_page( $path ): bool { $params = [ 'page' => PageController::PAGE_ROOT, 'path' => $path, ]; return 2 === count( array_intersect_assoc( $_GET, $params ) ); // phpcs:disable WordPress.Security.NonceVerification.Recommended } }