Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created June 19, 2012 14:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save thefuxia/2954622 to your computer and use it in GitHub Desktop.
Save thefuxia/2954622 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.20
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*
* Changelog
* 2012.06.20
* removed text-shadow from hook box
*/
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"
);
$vars = array (
'$pagenow: ' . $current_screen->id
);
$type = empty ( $current_screen->post_type )
? FALSE : $current_screen->post_type;
if ( $type )
{
$vars[] = '$typenow: ' . $type;
if ( did_action( 'add_meta_boxes_' . $type ) )
{
$hooks[] = 'add_meta_boxes_' . $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',
'text-shadow':'none',
'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
}
@bueltge
Copy link

bueltge commented Jun 21, 2012

A post on WPE would fine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment