Unified theory of electron–phonon renormalization and phonon-assisted optical absorption