Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Easy Debug Action and Filter Hooks in Wordpress
<?
/*
* add the following code to the add_filter and do_action function in the wp-includes/plugin.php
function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
global $wp_filter, $merged_filters;
*/
// debug Filter
preg_match_all('/gettext/', $tag, $match);
if(!$match[0][0]){
$hookinfo = func_get_args();
$canuseargs = count(func_get_args())-2;
echo '<div style="border:1px solid;padding:15px;margin:10px"><small>Filtername:</small> <font color="#cc0000">'.$tag.'</font><br /><small>Auszuführende Funktion:</small> <font color="#cc0000">';
#var_dump($hookinfo,$hookinfo[1]);
if (is_array($function_to_add)){
print_r($function_to_add);
}else{
echo $function_to_add;
}
echo '</font><br /><small>Aanzahl akzeptiere Argumente:</small> <font color="#cc0000">'.$canuseargs.'</font><br /></div>';
}
*/
/*
}
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
*/
// debug action */
echo '<h3>Action: <font color="#cc0000">'.$tag.'</font></h3>
<pre><p style="border:1px solid;padding:15px;">
<small>Filtername:</small> <font color="#cc0000">'.$tag.'</font><br />
<small>Argumente:</small> <font color="#cc0000">';
if (is_array($arg) || is_object($arg)){
print_r($arg);
}else{
echo $arg;
}
echo '</font></p></pre>';
// }
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.