id, $helix_pages, true ) ) { return; } // Check if user wants to use default WordPress admin. $use_default_admin = get_option( 'helix_use_default_admin', false ); if ( $use_default_admin ) { return; } // Don't redirect if Helix is not ready or the user opted into default admin. if ( ! helix_should_hijack_admin() ) { return; } // Don't redirect critical WordPress admin functions. global $pagenow; $critical_pages = array( 'admin-ajax.php', 'admin-post.php', 'async-upload.php', 'update.php', 'update-core.php', 'upgrade.php', ); if ( in_array( $pagenow, $critical_pages, true ) ) { return; } // Capture the current admin URL to pass to Helix for routing. $current_url = helix_normalize_route( filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL ) ); // Build the redirect URL with the original path for React routing. // Always use '&' because admin.php already has a query string (page=helix). $redirect_url = admin_url( 'admin.php?page=helix&helix_route=' . rawurlencode( $current_url ) ); // Redirect all other admin pages to Helix. wp_safe_redirect( $redirect_url ); exit; } );