Skip to content

Instantly share code, notes, and snippets.

@maxxscho
Forked from thefuxia/toolbar-hooks.php
Created June 19, 2012 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxxscho/2955450 to your computer and use it in GitHub Desktop.
Save maxxscho/2955450 to your computer and use it in GitHub Desktop.
T5 Toolbar hooks: Adds a toolbar item with the current page hooks.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Toolbar hooks
* Description: Adds a toolbar item with the current page hooks.
* Version: 2012.06.19
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
add_action( 'admin_print_footer_scripts', 't5_toolbar_hooks' );
function t5_toolbar_hooks()
{
global $hook_suffix, $current_screen;
$hooks = array (
"admin_print_styles-$hook_suffix",
"admin_print_scripts-$hook_suffix",
"admin_head-$hook_suffix",
"admin_footer-$hook_suffix",
'$pagenow: ' . $current_screen->id
);
$type = empty ( $current_screen->post_type )
? FALSE : $current_screen->post_type;
$type && $hooks[] = '$typenow: ' . $type;
?>
<script>jQuery(function($) {
var linkCss = {
'padding': '0 10px',
'cursor': 'pointer',
},
hookboxcss = {
'background': '#fff',
'border': '4px solid #080',
'color': '#000',
'display': 'none',
'font': '1em/1.2 monospace',
'padding': '5px',
'position': 'absolute',
'right': '0px',
'top': '28px',
'width': '300px'
},
hookbox = $('<pre><?php print implode( '\n', $hooks ); ?></pre>')
.css(hookboxcss),
hooklink = $('<a>Hooks</a>')
.click(function(){ hookbox.toggle(); })
.css(linkCss),
li = $('<li></li>')
.append(hooklink)
.append(hookbox);
$('#wp-admin-bar-top-secondary').append(li);
});</script><?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment