get_nodes(); if ( $all_nodes ) { if ( WP_DEBUG ) { $node_meta = array( 'title' => esc_html__( 'ABMP debug mode', 'admin-bar-menu-packer' ) ); } else { $node_meta = ''; } $wp_admin_bar->add_node( array( 'id' => 'abmp-root', 'title' => '', 'meta' => $node_meta, ) ); foreach ( $all_nodes as $node ) { $node_count += 1; if ( in_array( $node->id, $excluding_ids, true ) ) { continue; } else if ( in_array( $node->parent, $excluding_ids, true ) ) { $excluding_ids[] = $node->id; } else { if ( !$node->parent ) { $wp_admin_bar->remove_node( $node->id ); } if ( WP_DEBUG ) { $node_meta = array( 'class' => 'abmp-item', 'title' => $node_count . ' ' . $node->id ); } else { $node_meta = array( 'class' => 'abmp-item' ); } $args = array( 'id' => 'abmp-' . $node->id, 'title' => strip_tags( $node->title ), 'href' => $node->href, 'meta' => $node_meta, ); if ( isset( $node->parent ) && $node->parent && $node->parent !== 'top-secondary' ) { $args['parent'] = 'abmp-' . $node->parent; } else { $args['parent'] = 'abmp-root'; } $wp_admin_bar->add_node( $args ); $packed += 1; } } if ( $packed == 0 ) { $args = array( 'id' => 'abmp-no-item', // translators: label when the menu is empty 'title' => '(' . strip_tags( __( 'no items', 'admin-bar-menu-packer' ) ) .')', 'parent' => 'abmp-root', ); $wp_admin_bar->add_node( $args ); } abmp_hide_howdy( true ); if ( WP_DEBUG ) abmp_debug_menu( $all_nodes ); } } add_action( 'admin_notices', 'abmp_admin_notices' ); function abmp_admin_notices() { if ( WP_DEBUG ) { // translators: %s is plugin name $debug_notice1 = sprintf( esc_html__( '%1$s is currently working in debug mode, because WP_DEBUG is set to true.', 'admin-bar-menu-packer' ), ABMP_NAME ); // translators: %s is the label for debug menu ('All Nodes ID') $debug_notice2 = sprintf( esc_html__( 'Each item in the menu has a title attribute including the node ID, and a debug menu %s containing all items\' node ID is displayed.', 'admin-bar-menu-packer' ), '\'All Nodes\'' ); $class = 'notice notice-warning is-dismissible'; printf( '
%2$s
%3$s