WordPress Admin Tooltip hooks

Here is the simplest implementation I know of since there is no real API:

//add the needed scripts and styles
add_action('admin_enqueue_scripts', 'wpse_46028_enqueue_admin_scripts');
function wpse_46028_enqueue_admin_scripts() {
    wp_enqueue_style('wp-pointer');
    wp_enqueue_script('wp-pointer');
    //hook the pointer 
    add_action('admin_print_footer_scripts', 'wpse_46028_print_footer_scripts' );
}
function wpse_46028_print_footer_scripts() {
    $pointer_content="<h3>WordPress Answers</h3>";
    $pointer_content .= '<p>This is your pointer content</p>';
?>
   <script type="text/javascript">
   //<![CDATA[
   jQuery(document).ready( function($) {
    //jQuery selector to point to 
    $('#menu-dashboard').pointer({
        content: '<?php echo $pointer_content; ?>',
        position: 'top',
        close: function() {
            // This function is fired when you click the close button
        }
      }).pointer('open');
   });
   //]]>
   </script>
<?php
}

Leave a Comment