Skip to content

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

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 );
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ContributorDayIssues flagged as Contributor Day candidates.[Plugin] Optimization DetectiveIssues for the Optimization Detective plugin[Type] EnhancementA suggestion for improvement of an existing feature

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions