Sayyiduna Ibn Abbas (may Allah be pleased with them both) said: Women in nifas will wait seven (days); if they become pure, well and good; otherwise fourteen (days); if they become pure, well and good; otherwise twenty-one (days); if they become pure, well and good; otherwise forty (days she will wait), then she will pray.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحيض / 1610