Created
September 18, 2012 13:50
-
-
Save MrMaz/3743211 to your computer and use it in GitHub Desktop.
WordPress Admin Bar: Modal Window Link
This file contains hidden or 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 | |
/** | |
* Setup admin bar item which opens URL in a thickbox window | |
* | |
* @param WP_Admin_Bar $wp_admin_bar | |
*/ | |
function admin_bar_menu_modal_window( $wp_admin_bar ) | |
{ | |
// add "tools" node | |
// this is just our root node, nothing special here | |
$wp_admin_bar->add_node( array( | |
'id' => 'mytools', | |
'title' => 'My Tools', | |
'meta' => array( | |
'class' => 'mytools-top' | |
) | |
)); | |
// add "do stuff" link | |
$wp_admin_bar->add_node( array( | |
// id is required, but not important in this case | |
'id' => 'mytools-dostuff', | |
// set the parent to our root node | |
'parent' => 'mytools', | |
// this title is the <a> tag *content* | |
'title' => 'Do Stuff', | |
// notice the plugin page and thickbox iframe hint params | |
'href' => admin_url( 'admin.php' ) . '?page=mytools&_iframe=true', | |
// these meta attributes allow us to work some jQuery magic | |
'meta' => array( | |
// optional class for styling | |
'class' => 'mytools-sub' | |
// the link title *attribute* becomes the thickbox window title | |
'title' => 'Do Stuff Window Title', | |
// call jQuery statically to add the thickbox class on click | |
'onclick' => 'jQuery(this).addClass("thickbox");' | |
) | |
)); | |
} | |
add_action( 'admin_bar_menu', 'admin_bar_menu_modal_window', 999 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this.
typo - missing comma
change ‘class’ => ‘mytools-sub’ to ‘class’ => ‘mytools-sub’,
Also please
how/where to enter content