[wp-hackers] Getting the entire HTML page generated from WordPress

Brian Layman wp-hackers at thecodecave.com
Mon Feb 6 19:53:04 UTC 2012

That looks like it's the right idea..

The basic paradigm is:

Somewhere very early on do
ob_end_clean(); // Ensure a clean buffer.

On the "wp" or "init" action should be fine.

Then, as the very last thing you do, capture, process and echo the results
$body = ob_get_contents();
ob_end_clean();  // Clear the results so the unaltered stuff isn't sent
echo makeItBetter($body);

Perhaps in the "shutdown" action. (I've heard rumors of times shutdown 
is not called, I have no specifics on that. That may just have been when 
a die() was hit.)

Headers, if you need them, can be gotten through $headers = headers_list();

You could even do this code before and after the wp stuff in the main 
index.php, but you're likely to be slapped in the face with a large 
trout if you try something as hackish as that.

Hope that helps,

Brian Layman

On 2/6/2012 2:26 PM, Mario Peshev wrote:
> I've tried one solution from stackexchange:
> http://wordpress.stackexchange.com/a/41351/11506
> Didn't seem to work though

More information about the wp-hackers mailing list