Adaptive Wide Angle is one of Photoshop's secret weapons – so secret that many people have never even heard of it. If you want to correct the foreshortening effect that appears in many interior shots and cityscapes, it's perfect.
In this image (which is available on Unsplash.com thanks to photographer Roberto Nickson) all the vertical and horizontal lines converge on points so far outside the image that we can't actually see them. To fix this, choose 'filter > adaptive wide angle'.
This opens the image in a separate panel where there are only a few tools available. At the top on the right you can choose the kind of distortion you want to start with...but in this case, none of them really worked, so I left it on 'fisheye'. This certainly is NOT a 'fisheye' image, but that choice only caused very slight distortions of the vertical shapes, so I decided to start with it. I also reduced the 'scale' setting so the entire image was visible in the window.
To make something vertical, hold down the 'shift' key and click and drag down it. There are some well-defined vertical shapes in the wall on the left, and I dragged a line down one of them. As soon as you let go (with the mouse, not the shift key) that part of the image snaps to being vertical. Then I repeated the process using the edge of the wall visible on the right side. Finally, I dragged horizontally across the horizon. Sometimes when you drag, the line curves slightly to match the shape – as was the case here. When I released the mouse, the entire horizon became a flat, horizontal line.
If you just want to straighten a shape, click and drag along it but don't hold down the shift key, then it isn't constrained to horizontal and vertical. This means I could straighten out the top and bottom of the window frame which are both slightly curved in the original image.
The vertical wall on the right was now very slightly curved and therefore not quite on the line I'd dragged...so I tried switching from 'fisheye' to 'perspective', and that fixed it.
I increased the scale until the image just touched the sides, then clicked OK. Then I cropped it with the Crop tool. Did I add a few little bits to the corners with the Clone Stamp tool? Maybe...
Usually this kind of adjustment is all that's required to fix the vertical and horizontal shapes in an image. In fact, this window does a lot more – but that's another story.