We give a mathematical definition of irregular conformal blocks in the genus-zero WZNW model for any simple Lie algebra, using modules for affine Lie algebras whose parameters match up with those of moduli spaces of irregular meromorphic connections. The Segal--Sugawara representation of the Virasoro algebra is used to show that the spaces of irregular conformal blocks assemble into a flat vector bundle over the space of tame isomonodromy times, and we provide a universal version of the resulting flat connection. Finally we give a generalisation of the dynamical Knizhnik--Zamolodchikov connection of Felder--Markov--Tarasov--Varchenko