Last active
September 2, 2021 17:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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