Rewrite using OOP best practices

The code has been greatly cleaned up, with all the PHP logic now happening within a single file. Also, lots of redundancies (such as finding valid post types) have been eliminated.