Skip to content

Commit 63b93a2

Browse files
committed
Close buffer on shutdown
1 parent 4d9cc2e commit 63b93a2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

inc/manager.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public function register_hooks() {
382382
);
383383
add_action( 'template_redirect', [ $this, 'register_after_setup' ] );
384384
add_action( 'rest_api_init', [ $this, 'process_template_redirect_content' ], PHP_INT_MIN );
385-
385+
add_action( 'shutdown', [ $this, 'close_buffer' ] );
386386
foreach ( self::$loaded_compatibilities as $registered_compatibility ) {
387387
$registered_compatibility->register();
388388
}
@@ -696,12 +696,19 @@ public function process_template_redirect_content() {
696696
remove_filter( 'the_content', [ $this, 'process_images_from_content' ], PHP_INT_MAX );
697697

698698
ob_start(
699-
[ &$this, 'replace_content' ],
700-
0,
701-
PHP_OUTPUT_HANDLER_CLEANABLE
699+
[ &$this, 'replace_content' ]
702700
);
701+
703702
}
704703

704+
/**
705+
* Close the buffer and flush the content.
706+
*/
707+
public function close_buffer() {
708+
if ( self::$ob_started && ob_get_length() ) {
709+
ob_end_flush();
710+
}
711+
}
705712
/**
706713
* Throw error on object clone
707714
*

0 commit comments

Comments
 (0)