3278 | | * |
| 3278 | * Only use $disable_compression for pages that need to be updated continuously, like updating the core, |
| 3279 | * or installing plugins, etc. |
| 3280 | * |
| 3281 | * Turn off compression - make sure to flush the buffer BEFORE |
| 3282 | * turning off compression, see comment from Sam Yong |
| 3283 | * @link http://php.net/manual/en/function.ob-end-clean.php |
| 3284 | * |
| 3285 | * Turn off mod_deflate |
| 3286 | * @link http://httpd.apache.org/docs/2.2/env.html#no-gzip |
| 3287 | * |
| 3288 | * @param bool $disable_compression Turn off zlib / gzip compression, attempt to defeat chunking. |
| 3289 | * @return void |
3281 | | function wp_ob_end_flush_all() { |
3282 | | $levels = ob_get_level(); |
3283 | | for ($i=0; $i<$levels; $i++) |
3284 | | ob_end_flush(); |
| 3292 | function wp_ob_end_flush_all($disable_compression = false) { |
| 3293 | |
| 3294 | // Clean the output buffer |
| 3295 | $levels = ob_get_level(); |
| 3296 | for ($i=0; $i<$levels; $i++) |
| 3297 | ob_end_flush(); |
| 3298 | |
| 3299 | if ( $disable_compression ) { |
| 3300 | if ( !headers_sent() && ini_get('zlib.output_handler') ) { |
| 3301 | ini_set('zlib.output_handler', ''); |
| 3302 | ini_set('zlib.output_compression', 0); |
| 3303 | } |
| 3304 | |
| 3305 | // Tell apache to send an uncompressed non-chunked response |
| 3306 | if ( function_exists('apache_setenv') ) { |
| 3307 | apache_setenv( 'no-gzip', '1' ); |
| 3308 | } |
| 3309 | |
| 3310 | // Turn off any default output handlers |
| 3311 | ini_set('output_handler', ''); |
| 3312 | ini_set('output_buffering', false); |
| 3313 | ini_set('implicit_flush', true); |
| 3314 | |
| 3315 | // Pad the output by a 4K block just to make sure that whatever |
| 3316 | // apache/php considers a "chunk" is sent |
| 3317 | // 8 chars x 512 repetitions = 4,096 chars |
| 3318 | echo str_repeat('<!-- -->', 512); |
| 3319 | flush(); |
| 3320 | } |