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 | * For a more detailed explanation of this function, see |
| 3289 | * @link http://core.trac.wordpress.org/ticket/18525 |
| 3290 | * |
| 3291 | * @param bool $disable_compression Turn off zlib / gzip compression, attempt to defeat chunking. |
| 3292 | * @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(); |
| 3295 | function wp_ob_end_flush_all($disable_compression = false) { |
| 3296 | |
| 3297 | // If the script is called through CLI for any reason, bail |
| 3298 | if ( 'cli' == php_sapi_name() ) |
| 3299 | return; |
| 3300 | |
| 3301 | // Clean the output buffer |
| 3302 | $levels = ob_get_level(); |
| 3303 | for ($i=0; $i<$levels; $i++) |
| 3304 | @ob_end_flush(); |
| 3305 | |
| 3306 | if ( $disable_compression ) { |
| 3307 | if ( !headers_sent() && ini_get('zlib.output_handler') ) { |
| 3308 | ini_set('zlib.output_handler', ''); |
| 3309 | ini_set('zlib.output_compression', 0); |
| 3310 | } |
| 3311 | |
| 3312 | // Tell apache to send an uncompressed non-chunked response |
| 3313 | if ( function_exists('apache_setenv') ) |
| 3314 | apache_setenv( 'no-gzip', '1' ); |
| 3315 | |
| 3316 | // Turn off any default output handlers |
| 3317 | ini_set('output_handler', ''); |
| 3318 | ini_set('output_buffering', false); |
| 3319 | ini_set('implicit_flush', true); |
| 3320 | |
| 3321 | // Pad the output by a 4K block to ensure that the server / browser |
| 3322 | // considers the output sufficient |
| 3323 | echo '<!--' . str_repeat(chr(0), 4089) . '-->'; // 4096 bytes |
| 3324 | flush(); |
| 3325 | } |