Skip to content

Instantly share code, notes, and snippets.

@onnimonni
Last active September 2, 2021 17:08
Show Gist options
  • Save onnimonni/4af8bbf095a14cab272d to your computer and use it in GitHub Desktop.
Save onnimonni/4af8bbf095a14cab272d to your computer and use it in GitHub Desktop.
My helper for debugging wordpress filter the_content. put it in mu-plugins
<?php
/*
Plugin Name: Debug filters for WordPress
Version: 0.1
Author: Onni Hakala
Author URI: http://seravo.fi
*/
if (isset($_GET['debug']) && $_GET['debug']=='filters') {
//remove_filter( 'the_content','capital_P_dangit');
//remove_filter( 'the_content','do_shortcode');
add_action('wp_head','koodimonni_debug_output_for_filters');
function koodimonni_debug_output_for_filters() {
global $wp_filter;
?>
<pre>
<?php var_dump($wp_filter['the_content']); ?>
</pre>
<?php
}
add_filter( 'the_content', 'koodimonni_debug_filter_content', 10);
function koodimonni_debug_filter_content($value) {
echo "<h1>The content value:</h1>";
echo "<pre>";
var_dump($value);
echo "</pre>";
}
add_action('shutdown','koodimonni_output_debug_filter');
function koodimonni_output_debug_filter() {
// Pass the filter name here
echo "<h1>The content</h1>";
global $wp_filter;
echo "<pre>";
var_dump($wp_filter['the_content']);
echo "</pre>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment