[wp-trac] [WordPress Trac] #19371: As of 3.3beta2 WP_Admin_Bar no longer provides a way to access attributes of existing menu items

WordPress Trac wp-trac at lists.automattic.com
Thu Dec 1 21:00:34 UTC 2011


#19371: As of 3.3beta2 WP_Admin_Bar no longer provides a way to access attributes
of existing menu items
------------------------------+-----------------------
 Reporter:  willshouse        |       Owner:  nacin
     Type:  defect (bug)      |      Status:  reopened
 Priority:  high              |   Milestone:  3.3
Component:  Admin Bar         |     Version:  3.3
 Severity:  minor             |  Resolution:
 Keywords:  has-patch commit  |
------------------------------+-----------------------

Comment (by willshouse):

 > It should be noted, though, that get_nodes() generally returns a flat
 list of nodes

 What you mean when you say that it generally returns a flat list of nodes?
 This is the output I'm looking at:

 {{{
 add_action( 'admin_bar_menu', function( $admin_bar ) {
         $z = $admin_bar->get_nodes();
         print_r($z);
 },11);
 }}}


 {{{
 Array
 (
    [root] => stdClass Object
    (
     [id] => root
     [title] =>
     [parent] =>
     [href] =>
     [group] =>
     [meta] => Array
      (
      )

    )

    [wp-logo] => stdClass Object
    (
     [id] => wp-logo
     [title] => <span class="ab-icon"></span>
     [parent] =>
     [href] => http://nightly.dev/wp-admin/about.php
     [group] =>
     [meta] => Array
      (
       [title] => About WordPress
      )

    )
 ... (items removed for brevity)...
 )
 }}}

  I do like your idea of a "flat" list but I think an array or object might
 be better as that would show the parent / child relationship. I have no
 problem with the `print_r` type of array object that is above, but a
 simpler nested array of id's would also be fine.

 > If I had to guess, orphaning them.

 The only problem is that if you want to remove child nodes, and you orphan
 them by removing their parent menu item, and then add back a parent menu
 item with the same ID, the child nodes still show up. So possibly we do
 need to look at doing the `unset( $argschildren? )`, and maybe also
 unsetting the group argument too?

 Mostly I would be very happy if "`get nodes`"  gets changed to a public
 function before 3.3 is released.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19371#comment:32>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list