menu->edit['title'] * v.0.2: 110224 (efc) moved to a plugin * using the $wp_admin_bar->add_menu method * v.0.1: 110224 (efc) implemented in theme */ /* * Relevant WP core files: * http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-admin-bar.php * http://core.trac.wordpress.org/browser/trunk/wp-includes/admin-bar.php * * Explanation of changes for WP3.3 * http://wpdevel.wordpress.com/2011/12/07/admin-bar-api-changes-in-3-3/ * */ function efc_admin_bar_menu() { global $wp_admin_bar; global $wp_version; $current_object = get_queried_object(); // IDs live in different places for posts or taxonomy items, why? if (! empty ( $current_object->post_type ) ) { $id = $current_object->ID; } elseif (! empty ( $current_object->taxonomy ) ) { $id = $current_object->term_id; } else { $id = ""; } // update the menu title, which is a different process before and after WP 3.3 if ( $wp_version >= 3.3 ) { if ( is_object($node = $wp_admin_bar->get_node('edit')) ) { $wp_admin_bar->add_node( array( 'id' => 'edit', 'title' => $node->title . " $id", ) ); } } else { if( is_array($wp_admin_bar->menu->edit) && $id ) { // is there an edit menu? $wp_admin_bar->menu->edit['title'] .= " $id"; // then append the id } } } // note that this action will fire late, // after $wp_admin_bar has been populated add_action( 'admin_bar_menu', 'efc_admin_bar_menu', 95 ); ?>