WP Manifestindependent plugin directory
manifest / developer / wordpress-output-buffering

Output Buffering WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

A simple mu-plugin that buffers the entire WP process, capturing the final output for DOM manipulation.

★ 16stars
34release downloads
≈10active sites
1.0.5latest · 7 years ago

Install

Download output-buffering-1.0.5.zip From the 1.0.5 release on GitHub, Nov 17, 2018

Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/dmhendricks/wordpress-output-buffering/releases/download/1.0.5/output-buffering-1.0.5.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

A simple mu-plugin that buffers the entire WP process, capturing the final output for DOM manipulation.

Original code by kfriend on Stack Overflow. Licensed as GPL because it is a WordPress derivative.

Installation

To install, simply download and copy output-buffering.php to your /wp-content/mu-plugins directory.

Requires PHP 5.3 or higher.

Tip

Use HtmlPageDom in conjunction for jQuery-like DOM manipulation in PHP.

Usage

Simple Example

This code will replace any instance of "foo" on the web page with "bar":

add_filter( 'final_output', function( $output ) {
    return str_replace( 'foo', 'bar', $output );
});

Configuration

By default, output buffering is only enabled on the frontend of the site and is disabled for WP Admin and during AJAX requests.

You can modify this behavior and specify on which request/screen types that you want to enable it by adding the following constants to wp-config.php:

PHP (PHP 5.3+)

define( 'OB_ENABLE_ADMIN', true ); // Enables output buffering in WP Admin
define( 'OB_ENABLE_AJAX', true ); // Enables output buffering during AJAX calls

PHP 7.0 and Higher

define( 'OB_REQUEST_TYPES', array( 'site', 'admin', 'ajax' ) ); // Case-sensitive

In the example above, output buffering is enable on the frontend ("site"), in WP Admin ("admin") and during AJAX requests ("ajax"). Add or remove from the array as desired. For example, to only load output buffering in WP Admin and not on the frontend or during AJAX calls:

define( 'OB_ENABLE_SCREENS', array( 'admin' ) );

Caution

Take care when changing this behavior! You may experience issues when enabling in WP Admin or during AJAX calls if your manipulation logic interferes with normal WordPress function.

Always test first before using in a production setting!

Changelog

1.0.5

  • Disable output buffering for WP-CLI

1.0.4

  • Disabled for WP JSON (Gutenberg compatibility)

1.0.3

  • Added wp-config.php constants to control where output buffering is enabled.

Releases

3 releases. Each count is every asset in that release; expand a row for the breakdown.

Tag
Published
Assets
Downloads
1.0.5 latest
Nov 17, 2018 7 years ago
output-buffering-1.0.5.zip
15
Jul 1, 2018 8 years ago
output-buffering-1.0.4.zip
9
Mar 24, 2018 8 years ago
output-buffering-1.0.3.zip
10

Active-site estimate ≈10 comes from the median of recent superseded releases. Method.

A grade

Security

Output Buffering 1.0.5 · audited by WP Registry

No security issues found.

Audited release
1.0.5
Findings
none
Worst severity
—
Content hash
d2126b6fafe19d9523c9ef37…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.