I'm more inclined to believe that Erdogan had a hand in setting up a coup that could be easily squashed so as to purge his staunchest opponents.
An important aspect that's being ignored is that Turkey is a NATO nation. Who initiated the attempted coup doesn't change how troubling it is that by treaty we're obligated to defend them.
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.