title: Modify the wordpress admin bar to add custom messages
body: <p>I'm trying to convert the Wordpress admin bar into something more useful for the registered users. My client has asked me to add into that bar a space to display instant messages that will appear for a few seconds and then dissapear. The idea is that this space will allow the users who are online to see if someone is messaging them like a chat.</p>
  
  <pre><code>class MessageMenu{
      function MessageMenu(){
          add_action( 'admin_bar_menu', array( $this, 'message_section' ) );
      }
  
      function add_message( $message, $timeout = 2000 ){
          // This function should add a new live message to the admin bar
          // First it should check if there is a current message
          // Then write the new message
          global $wp_admin_bar;
      }
  
      function message_section(){
          // This function will supposedly create a 
          global $wp_admin_bar;
          $args = array(
              'id'    =&gt; 'message_section',
              'title' =&gt; __( 'Mensajes' ),
              'parent'=&gt; false,
              'href'  =&gt; false,
              'group' =&gt; true );
          $wp_admin_bar-&gt;add_node( $args );
          $this-&gt;add_message( 'Live messages' );
      }
  }
  
  function MessageMenuInit(){
      global $MessageMenu;
      $MessageMenu = new MessageMenu();
  }
  add_action( 'init', 'MessageMenuInit' );
  </code></pre>