Adiabatic and nonadiabatic phonon dispersion in a Wannier function approach