• Can anyone tell me how I can add widgets to the admin bar?

    I’ve created the widget area and added a custom menu to the admin bar (via the add_menu API), but I’m not sure how to add the PHP code to call the widget area inside of the add_menu function. I’m not the best with PHP so any advice or snippets would be appreciated. Thanks.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The admin toolbar was never intended to be wigetized, thus the add_menu() and add_node() methods only accept straight HTML as content, no PHP. Which would be OK if widgets accumulated output like shortcode callbacks. However, as you know, widgets send output straight to the browser, you cannot pass the output to the add_node() method.

    Or can you? Look into using the PHP output buffers to capture widget output, then pass the buffer content to add_node() as HTML. No promises this will work, but I think it is your best bet.

Viewing 1 replies (of 1 total)

The topic ‘Widgets in Admin Bar’ is closed to new replies.