Created
March 31, 2011 00:38
-
-
Save scribu/895598 to your computer and use it in GitHub Desktop.
WordPress Hooks & Filters Flow
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 | |
/* | |
Script Name: Wordpress Hooks & Filters Flow | |
Plugin URI: http://planetozh.com/blog/my-projects/wordpress-hooks-filter-flow/ | |
Description: Lists hooks and their associated filters/actions for your blog. Meant to provide debugging help. | |
Version: 1.0 | |
Author: Ozh | |
Author URI: http://planetOzh.com/ | |
*/ | |
// Put this file either in your blog root or in '/wp-admin' | |
if (file_exists('./wp-blog-header.php')) { | |
require('./wp-blog-header.php'); | |
} elseif (file_exists('../wp-blog-header.php')) { | |
require('../wp-blog-header.php'); | |
} else die('File <code>wp-blog-header.php</code> not found. This script you are trying to run must sit either in your blog root or in <code>wp-admin</code> directory'); | |
?> | |
<html> | |
<head> | |
<title>Wordpress Hooks & Filters Flow</title> | |
<link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" /> | |
<?php | |
if (file_exists(ABSPATH.'wp-content/plugins/widgets/scriptaculous/scriptaculous.js')) { | |
$sillyjs=1; | |
?> | |
<script language="JavaScript" type="text/javascript" src="<?php echo get_settings('siteurl') ?>/wp-content/plugins/widgets/scriptaculous/prototype.js"></script> | |
<script language="JavaScript" type="text/javascript" src="<?php echo get_settings('siteurl') ?>/wp-content/plugins/widgets/scriptaculous/scriptaculous.js"></script> | |
<script language="JavaScript" type="text/javascript" src="<?php echo get_settings('siteurl') ?>/wp-content/plugins/widgets/scriptaculous/dragdrop.js"></script> | |
<?php } ?> | |
</head> | |
<body> | |
<div id="wphead"><h1>Hooks & Filters Flow</h1></div> | |
<p class="wrap">Below is an alphabetically ordered list of Wordpress 'hooks' and their associated filters / actions (i.e. PHP functions) on this Wordpress install.</p> | |
<div class="wrap"> | |
<?php if ($sillyjs) { ?> | |
<div id="hookcontrol"> | |
<span id="hookoff" title="Fold every hook">-</span> | |
<span id="hookon" title="Unfold every hook">+</span> | |
<span id="hooktoggle" title="Toggle every hook">toggle</span> | |
</div> | |
<?php } ?> | |
<ol> | |
<?php | |
ksort($wp_filter); | |
$nb_hook = 0; | |
$nb_func = 0; | |
foreach($wp_filter as $hook => $arrays) { | |
$nb_hook ++; | |
$sillyjs?$stuff="style='cursor:pointer;' onclick='Effect.toggle(\"li$nb_hook\",\"blind\",{duration:0.2});'":$stuff=''; | |
echo "<li><h2 $stuff title='Hook : $hook'>$hook</h2>\n<ul id='li$nb_hook'>\n"; | |
ksort($arrays); | |
foreach($arrays as $prio => $subarray) { | |
echo "<li>Priority <strong>$prio</strong> : <ol>\n"; | |
foreach($subarray as $sub) { | |
$nb_func ++; | |
echo '<li><code>'; | |
$func = $sub['function']; | |
if (is_array($func)) { | |
echo '<em>'.get_class($func[0]) . '-></em>' . $func[1].'()'; | |
foreach ($func[0] as $k=>$v) { | |
if (substr($v,strlen($v)-4,strlen($v)) == '.php') echo " <small>($k : $v)</small>"; | |
} | |
} else { | |
echo $func.'()'; | |
} | |
echo "</code></li>\n"; | |
} | |
print '</ol>'; | |
} | |
print '</ul></li>'; | |
} | |
?> | |
</ol> | |
</div> | |
<div class="wrap"><p>Number of hooks : <?php echo $nb_hook; ?><br/> | |
Number of registered filters / actions : <?php echo $nb_func; ?></p> | |
</div> | |
<div id="footer"><p><a href="http://frenchfragfactory.net/ozh/my-projects/wordpress-hooks-filter-flow/">Wordpress Hooks & Filters Flow</a> — a plugin debugging tool by <a href="http://frenchfragfactory.net/ozh/" title="planetOzh">Ozh</a></p> | |
<p> </p></div> | |
<?php if ($sillyjs) { ?> | |
<style> | |
#hookcontrol{float:right;} | |
#hooktoggle,#hookon,#hookoff{cursor:pointer;text-align:center;background:#ddf;padding:.2em .3em;font-size:70%;border:1px solid #ccf;} | |
#hooktoggle:hover,#hookon:hover,#hookoff:hover{border:1px solid #aaf;background:#ccf} | |
</style> | |
<script type="text/javascript"> | |
<!-- | |
$('hooktoggle').onclick=function(){hooktoggle();}; | |
$('hookon').onclick=function(){hookon();}; | |
$('hookoff').onclick=function(){hookoff();}; | |
function hooktoggle() { | |
i=0; | |
$A(document.getElementsByTagName("h2")).each(function(){i++;Effect.toggle("li"+i,"appear",{duration:0.05});}); | |
} | |
function hookon() { | |
i=0; | |
$A(document.getElementsByTagName("h2")).each(function(){i++;Effect.BlindDown("li"+i,{duration:0.05});}); | |
} | |
function hookoff() { | |
i=0; | |
$A(document.getElementsByTagName("h2")).each(function(){i++;Effect.BlindUp("li"+i,{duration:0.05});}); | |
} | |
//--> | |
</script> | |
<?php } ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment