I look at the timing of the coup and it was done at a point when the united states was least likely to interfere with turkey in there clamp down and purge after words... we now have a real caliph when you combine turkey and the lands controlled by isil.
I really do think that isil has been a creation of Turkish intelligence and Islamists within turkey. this has been the culmination of six years of effort from turkey to create a Islamist state and our president helped in this effort or he at least ignored it.
The timing probably has more to do with their realization that Trump will win the election and that they no longer will have a complicit leader who is willing to look the other way. At least that is my opinion.
Anyway, much has been written to either support or question if Turkey has been supportive of ISIS. Here are but a few:
Turkey supports ISIS, wants to revive Ottoman Empire Syrias UN envoy
Turkeys alleged ISIS support: Absolutely horrendous
Is Turkey supporting ISIS? If so, why?
If you will notice all of this administrations activities have been leveled at the more moderate Islamic countries: Egypt, Libya, Syria. All of which had a more extremist Islamic view take control, or are trying to in the case of Syria. Of course, Egypt reversed that by forcibly removing the Muslim Brotherhood from power. But Obama's administration was not happy about that, though hardcore leftist would say otherwise.