Output buffering
-
Hi @spacetime,
I’m the developer of Smart Slider 3 and we have a compatibility issue with your plugin when the output buffering is turned on in Ad Inserter.As I see you start the output buffering when
init
action happen:#0 ai_buffering_start() called at [/var/*/wp-content/plugins/ad-inserter/ad-inserter.php:1528] #1 ai_init_hook() called at [/var/*/wp-includes/class-wp-hook.php:286] #2 WP_Hook->apply_filters(, Array ([0] => )) called at [/var/*/wp-includes/class-wp-hook.php:310] #3 WP_Hook->do_action(Array ([0] => )) called at [/var/*/wp-includes/plugin.php:465] #4 do_action(init) called at [/var/*/wp-settings.php:505]
And then you close it when
wp_footer
action happen:#0 ai_buffering_end() called at [/var*/wp-content/plugins/ad-inserter/ad-inserter.php:2940] #1 ai_wp_footer_hook() called at [/var*/wp-includes/class-wp-hook.php:286] #2 WP_Hook->apply_filters(, Array ([0] => )) called at [/var*/wp-includes/class-wp-hook.php:310] #3 WP_Hook->do_action(Array ([0] => )) called at [/var*/wp-includes/plugin.php:465] #4 do_action(wp_footer) called at [/var*/wp-includes/general-template.php:2684]
The problem is that you can not be sure that you are closing the output buffer which you opened earlier. This is why it is better to use
ob_start
callback and PHP will close your buffer automatically at the end of the scripts.Here is an example what works fine for us:
function my_output_buffer_callback($buffer, $phase){ if ($phase & PHP_OUTPUT_HANDLER_FINAL || $phase & PHP_OUTPUT_HANDLER_END) { // Here you can manipulate the $buffer return $buffer; } return $buffer; } ob_start('my_output_buffer_callback');
Probably the conflict happens with our plugin, because your plugin closes our output buffer which is opened by our plugin. It would be great if you could implement this suggestion into Ad Inserter.
Note: in the output callback you won’t be able to start new output buffer. If you need local output buffer to place small HTML parts into variables, better to render the content at
wp_footer
action and store it into a variable, then you can safely insert that in the output buffer callback.
- The topic ‘Output buffering’ is closed to new replies.