[wp-trac] [WordPress Trac] #43258: Output buffering

WordPress Trac noreply at wordpress.org
Tue Jun 8 07:50:22 UTC 2021


#43258: Output buffering
-------------------------+------------------------------
 Reporter:  nextendweb   |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  2nd-opinion  |     Focuses:  docs
-------------------------+------------------------------

Comment (by nextendweb):

 I propose the attached `WP_Output_Buffer` class, which would be an
 optional feature what developers could enable and use when needed. It
 simply starts an output buffer and runs the 'output_buffer' filter on the
 content of the buffer which holds the whole output of the site.

 Also the class gives suggested priorities for different use cases so
 developers can hook to the right point.

 {{{#!php
 <?php
 <?php
 if (class_exists('WP_Output_Buffer')) {
     WP_Output_Buffer::enable();

     add_filter('output_buffer', array(
         $this,
         'prepareOutput'
     ), WP_Output_Buffer::DEFAULT_PRIORITIES['CONTENT']);
 } else {
     /**
      * The plugin and theme mechanism for old WordPress version which do
 not support this feature.
      */
 }
 }}}


 Several huge plugins use global output buffers like:
 - Wordfence Security @mmaunder
 - Jetpack
 - Really Simple SSL @rogierlankhorst
 - SG Optimizer @hristo-sg
 - LiteSpeed Cache @litespeedtech
 - WP Fastest Cache @emrevona
 - Autoptimize @optimizingmatters
 - Smush @alexdunae
 - W3 Total Cache @joemoto
 - WP Rocket
 - EWWW Image Optimizer @nosilver4u
 - Smart Slider 3

 and much more: [https://wpdirectory.net/search/01F7N8YMPFH6Q9G4RGCPZAGAXS
 wpdirectory.net => ob_start\( ?array] and
 [https://wpdirectory.net/search/01F7N8VMX5412YX36TJ4T1DH88 wpdirectory.net
 => ob_start\(('|")]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43258#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list