Skip to content

Reuse template enhancement output buffer in Optimization Detective for WP 6.9 #2224

@westonruter

Description

@westonruter

Instead of Optimization Detective hackily opening its own output buffer via od_buffer_output() during the template_include filter:

add_filter( 'template_include', 'od_buffer_output', PHP_INT_MAX );

In WordPress 6.9 we can now leverage the template enhancement output buffer introduced via Core-43258 (see r60936). When the wp_start_template_enhancement_output_buffer() function exists, we can skip starting our own output buffer:

if ( ! function_exists( 'wp_start_template_enhancement_output_buffer' ) ) {
    add_filter( 'template_include', 'od_buffer_output', PHP_INT_MAX );
}

And then od_template_output_buffer() can be updated accordingly:

if ( function_exists( 'wp_start_template_enhancement_output_buffer' ) ) {
    add_filter( 'wp_template_enhancement_output_buffer', $callback );
} else {
    add_filter( 'od_template_output_buffer', $callback );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Not Started/Backlog 📆

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions