Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Support: Creating & Extending

Existing and new plugins/components and themes.

New plugin: Add All Nav Links to BP Adminbar (26 posts)

Started 1 year, 9 months ago by: pcwriter

  • Profile picture of pcwriter pcwriter said 1 year, 9 months ago:

    Thanks to loads of help from @hnla, I’ve popped my cherry and got my 1st plugin into the repo… hurray!

    This plugin aggregates all Buddypress directory and WordPress page links into the BP Adminbar.

    All BP directory pages (Members, Groups, Forums, etc.) are collected in a Community dropdown, including any directories from added plugins like BP-Links or BP-Gallery. All WP pages appear in dropdowns that respect whatever page order you have set in your WP backend. Child and grandchild pages appear in flyout subnavs.

    Several user configuration options have been included so you can customize your new admin/navbar to your heart’s content.

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

    http://wordpress.org/extend/plugins/add-all-nav-links-to-bp-adminbar/

  • Profile picture of @mercime @mercime said 1 year, 9 months ago:

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

  • Profile picture of Hugo Hugo said 1 year, 9 months ago:

    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.

  • Profile picture of Hugo Hugo said 1 year, 9 months ago:

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

  • Profile picture of pcwriter pcwriter said 1 year, 9 months ago:

    @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 :-)

  • Profile picture of Hugo Hugo said 1 year, 9 months ago:

    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.

  • Profile picture of pcwriter pcwriter said 1 year, 9 months ago:

    @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’ )); ‘;

  • Profile picture of Hugo Hugo said 1 year, 9 months ago:

    @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

  • Profile picture of pcwriter pcwriter said 1 year, 9 months ago:

    @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… :-(

  • Profile picture of Hugo Hugo said 1 year, 9 months ago:

    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

  • Profile picture of pcwriter pcwriter said 1 year, 9 months ago:

    @hnla

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

    Thanks!

  • Profile picture of Hugo Hugo said 1 year, 9 months ago:

    Ah not that knowledgeable, sadly :)

  • Profile picture of pcwriter pcwriter said 1 year, 9 months ago:

    @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?

  • Profile picture of Hugo Hugo said 1 year, 9 months ago:

    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

  • Profile picture of pcwriter pcwriter said 1 year, 9 months ago:

    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!