Skip to:
Content
Pages
Categories
Search
Top
Bottom

New plugin: Add All Nav Links to BP Adminbar

Viewing 25 replies - 1 through 25 (of 25 total)
  • @mercime

    Participant

    @pcwriter, congratulations! Will be checking this out.
    Cheers.

    @hnla

    Participant

    Re the additional elements added, There are two approaches: the embedded style rules could be combined, outputting a series of ‘style’ tags clutters the head; better that those display:none rules are injected into the same style tag function. I think though the correct approach with these adminbar elements is to use remove_actions rather than style rules I’ll try and re-factor the script for remove_actions.

    @hnla

    Participant

    @pcwriter Patrick you have changed the plugin directory name but you haven’t updated the loader file include path to reflect this.

    @pcwriter

    Participant

    @hnla

    Oops, my bad! Updated loader and readme. Thanks for that catch.
    remove_action does sound like a better approach. If you could provide an example of how to code such a function, the class would appreciate the exercise :-)

    @hnla

    Participant

    It’s not as straightforward as it ought to be there appear to be issues with the order of loading at least what is easily doable from functions.php becomes problematic as a plugin – I have had to wrap the remove_actions in a bp-init function and that provokes other questions as there appear to be conflicting docs on this aspect, most remove_actions I can get to work, site-logo refuses to play ball.

    @pcwriter

    Participant

    @hnla

    Here’s an interesting question from a user which would render the plugin more user-friendly in a WP3.0 environment:

    “How do you change the label of the $adminbarPages 1 & 2 to default to the name of the custom menus? In other words, I don’t want to hardcode the labels into the navbar. Instead, I’d like it to display the Custom Menu names.”

    Something like this maybe (I’ve omitted the “>” and “?” simply so the code would show here…)

    $adminbarPages1 = ‘ php echo wp_nav_menu( array(‘menu’ => ‘MENU-SLUG-HERE-I-THINK’ )); ‘;

    @hnla

    Participant

    @pcwriter oops sorry missed this post.

    That’s exactly what I was talking about and exactly what I had intended to implement but it probably got overlooked in the original thread, I spent a considerable amount of time reading through all the nav-menu files trying to see how these user added menu labels were referenced but couldn’t puzzle it out. I posted a topic on the WP support forums waited and waited re posted re phrasing the question but it was clearly too much for WP support to deal with ;-)

    I’m not happy with hardcoding the labels for custom menus it was never the real intention, I can try your code snippet but think I established that the menu name or slug isn’t available in that array, it’s more an admin dashboard object but I may be wrong. Just wish there was some serious documentation on the WP codex, at the moment two seemingly important functions are simply lacking any documentation

    @pcwriter

    Participant

    @hnla

    I may have found some clues here:
    http://adambrown.info/p/wp_hooks/hook/wp_get_nav_menus?version=3.0&file=wp-includes/nav-menu.php

    And from here:
    http://svn.automattic.com/wordpress/tags/3.0/wp-includes/nav-menu.php
    … there are these nifty tidbits:

    function wp_get_nav_menus( $args = array() ) {
    $defaults = array( ‘hide_empty’ => false, ‘orderby’ => ‘none’ );
    $args = wp_parse_args( $args, $defaults );
    return apply_filters( ‘wp_get_nav_menus’, get_terms( ‘nav_menu’, $args), $args );
    }

    function get_registered_nav_menus() {
    global $_wp_registered_nav_menus;
    if ( isset( $_wp_registered_nav_menus ) )
    return $_wp_registered_nav_menus;
    return array();
    }

    Looks like these functions should call whatever nav menus are set in the backend in 3.0 but, as I’m still VERY wet behind the ears when it comes to understanding what functions can actually do… :-(

    @hnla

    Participant

    Ok well done, they look promising; wp_get_nav_menus() was one of the functions that is referenced in the codex but has no page written for it and which I had been playing around with the functions above I’m not sure about but can break them down and the links look like useful reading

    I’ll have another look when I have a minute, but it’s one of those straightforward requirements that can end up being a tad more difficult than one had imagined

    @pcwriter

    Participant

    @hnla

    I’m just very grateful that someone knowledgeable is investing the time and effort to help out a motivated noob :-)

    Thanks!

    @hnla

    Participant

    Ah not that knowledgeable, sadly :)

    @pcwriter

    Participant

    @hnla Hiya teach!

    Progress report here on the next update for BP-WP-Navbar: an Option Configuration Admin Panel :-)

    I’ve managed to get my head around creating an admin panel under Settings in the WP backend with the basic hide/show function labels/radio buttons.
    Code here: http://pastebin.com/F29UtJFh

    Tables are created in the database but I can’t figure out what I need to change in the main file (bp-wp-navbar.php) to save the option values to the database so they take effect.

    So far, so good… but I’m stuck. Would you happen to have any clues or guidance on this bit?

    @hnla

    Participant

    Are tables and data created/saved in the DB? if they are then you should simply have to query the DB in bp-wp-navbar to fetch the field values and use those in place of the current variable strings.
    I haven’t time to look too deeply now but will try and run it tomorrow and have a look at the wp-nav menu names

    @pcwriter

    Participant

    Not quite… tables are created but the data is NOT saved. That’s where I’m stuck.
    Thanks again for the time you put in and… take your time, there’s no rush.
    I have to go pick up my bicycle from the shop and then I’m off to the amusement park to lose control for a while!

    @hnla

    Participant

    Enjoy the rides :) I’ll try and catch up later on tomorrow.

    @hnla

    Participant

    Accessing the menu names is sadly as difficult as I had first thought, I have two arrays that respectively hold the menu regions and menu object parts but finding a method to check one against the other is proving allusive. What I have established is that the menu name attached to a particular menu region does not belong to the nav-menu.php functions but more to the theme functions and makes things problematic, as a new method needs to be written to check a menu region for an explicit but unknown menu name and that isn’t proving simple to theorise let alone start writing.

    At this moment it is something that will have to, sadly, go on the back burner as the cost in time so far outweighs the end result, I’ll revisit as and when I get any inspiration on an approach to try but it may require someone far more familiar in the WordPress API than I am.

    @pcwriter

    Participant

    That’s kind of what I had understood too while I was trying to figure out the concept of “theme locations”, but I had hoped I was wrong… like I have often been before.
    I’ll see if I can dig up some other folks to also take a look. Personally, I’m treading unknown waters and I’m pretty lost in all this new stuff.

    Thanks again very much for all the help you’ve given me these past several days. Without it, I doubt this plugin would have been born, and my knowledge of how to do so would have been sadly lacking. ;-)

    @hnla

    Participant

    I have a question posed elsewhere on the issue but like the WP one I posted I don’t really hold out hope of a solution or even just hints, it looks as though this aspect wasn’t really considered and perhaps it’s not really something that would be required as the menu name isn’t something that needs to be accessed other than in the backend so the means for me to test a region and find out what menu has been assigned to it isn’t provided for even though the menu region at some point has to know what menu it is being asked to display so what I need is available somewhere, but that is why I need someone familiar with the new menu API to tell where and how to cross check data then I can write a function to check each menu region and return it’s associated menu name.

    @hcleary

    Member

    Thanks to y’all for looking into this menu issue.

    @pcwriter

    Participant

    Version 2.0 is out!

    All user configuration options are now available through an admin panel under “Settings” > “BP-WP-Navbar”.

    Enjoy :-)

    @hnla

    Participant

    Well done, I’ll take a look later, see if there are any issues. I’m still trying to figure out the labeling issue with the wp_nav_menu.

    @hnla

    Participant

    @pcwriter I’m trying to find out why the plugin group hasn’t got a forum activated, if it can be enabled I’ll close this thread off so that further discussions can continue within that group.

    @r-a-y

    Keymaster

    You have to go to the group admin settings and enable the discussion forum like on a regular BP install.

    Are you the group admin, pcwriter?

    @pcwriter

    Participant

    @hnla @r-a-y

    Oops… forum enabled (forgot about that) ;-)

    @hnla

    Participant

    Closing this thread then. Further discussions should continue in the plugin group:

    https://buddypress.org/community/groups/add-all-nav-links-to-bp-adminbar/

Viewing 25 replies - 1 through 25 (of 25 total)
  • The topic ‘New plugin: Add All Nav Links to BP Adminbar’ is closed to new replies.
Skip to toolbar