Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active August 3, 2025 21:41
Show Gist options
  • Save westonruter/9e9036e8dc11292279a90995273c7adc to your computer and use it in GitHub Desktop.
Save westonruter/9e9036e8dc11292279a90995273c7adc to your computer and use it in GitHub Desktop.
‼️ OBSOLETE: Plugin moved to a proper repo: https://github.com/westonruter/od-default-disabled

Installation

  1. Download the plugin ZIP from GitHub (see also link above).
  2. Visit Plugins > Add New Plugin in the WordPress Admin.
  3. Click Upload Plugin.
  4. Select the ZIP file on your system from step 1 and click Install Now.
  5. Click the Activate Plugin button.

You may also install and update via Git Updater.

<?php
/**
* Plugin Name: Optimization Detective Default Disabled
* Plugin URI: https://gist.github.com/westonruter/9e9036e8dc11292279a90995273c7adc
* Description: Disables Optimization Detective by default unless you supply the <code>?optimization_detective_enabled=1</code> query parameter. This allows you to debug issues on a live site without visitors seeing a broken experience.
* Requires at least: 6.5
* Requires PHP: 7.2
* Requires Plugins: optimization-detective
* Version: 0.1.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Text Domain: od-default-disabled
* Update URI: https://gist.github.com/westonruter/9e9036e8dc11292279a90995273c7adc
* Gist Plugin URI: https://gist.github.com/westonruter/9e9036e8dc11292279a90995273c7adc
* Primary Branch: main
*
* @package OptimizationDetective\DefaultDisabled
*/
namespace OptimizationDetective\DefaultDisabled;
add_filter(
'od_can_optimize_response',
static function ( $can_optimize ) {
if ( ! isset( $_GET['optimization_detective_enabled'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$can_optimize = false;
}
return $can_optimize;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment