Compatibility with the official AMP plugin
-
Hi. I’m an engineer working on the official AMP plugin. We’ve had various reports of your plugin not being compatible, which you state on your site as well.
However, I’m curious why it can’t be compatible?
From looking at your plugin’s codebase, it seems rooted in how output buffering is performed. You’re currently staring output buffering at
plugins_loaded
and then manually stopping the output buffer atshutdown
. I think compatibility could be improved in two ways:- Start output buffering at
template_redirect
. The AMP plugin opens its output buffer at the minimum priority (PHP_INT_MIN
), so if you start at priority0
then that will be compatible. Starting output buffering atplugins_loaded
seems excessively early. - Instead of gathering the output buffer at
shutdown
, simply provide a callback function in the call toob_start()
. This callback function then is passed the entire buffer at shutdown automatically, ensuring that it runs before other output buffers are closed.
You can refer to the AMP plugin’s codebase to see how we’re doing this. We are compatible with various caching plugins that do output buffering, including W3 Total Cache, WP Rocket, and WP Super Cache, etc. If you adjust how you do output buffering, then your plugin could have much better compatibility as well.
- Start output buffering at
- The topic ‘Compatibility with the official AMP plugin’ is closed to new replies.