My WPWrapper class

In my previous post, I mentioned that I had a really simple way of using my wordpress themes with regular PHP scripts. Now, according to the Codex, you are supposed to use this method:

include 'wp-blog-header.php';
get_header();
/* Do some code */
get_sidebar();
get_footer();

That works great and all, but from time to time you might change your theme to move your sidebar around or something. Now you’ve got a bunch of pages you need to update.

I’ve come up with a nifty solution that uses PHP’s output buffering callback system to catch whatever output happens and then stick it between wordpress’ get_* functions. The above code now becomes:

include 'wp-blog-header.php';
include 'WPWrapper.class.php';
WPWrapper::start()
/* Do some code */

Thanks to my commons system, I just need to do something like my documents page. Beautiful, innit?

For bonus points, read up on the API Documentation

Leave a Reply