Skip to:
Content

BuddyPress.org

Changeset 4867


Ignore:
Timestamp:
07/26/2011 01:25:17 PM (14 years ago)
Author:
boonebgorges
Message:

Introduces bp_nav_item_has_subnav(), to make it easier for theme and plugin developers to check whether a nav item's subnav is populated. See #3381. Props slaFFik.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-buddybar.php

    r4833 r4867  
    285285
    286286/**
     287 * Determines whether a given nav item has subnav items
     288 *
     289 * @package BuddyPress
     290 * @since 1.3
     291 *
     292 * @param str $nav_item The id of the top-level nav item whose nav items you're checking
     293 * @return bool $has_subnav True if the nav item is found and has subnav items; false otherwise
     294 */
     295function bp_nav_item_has_subnav( $nav_item = '' ) {
     296    global $bp;
     297   
     298    if ( !$nav_item )
     299        $nav_item = bp_current_component();
     300   
     301    $has_subnav = isset( $bp->bp_options_nav[$nav_item] ) && count( $bp->bp_options_nav[$nav_item] ) > 0;
     302   
     303    return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
     304}
     305
     306/**
    287307 * Removes a navigation item from the sub navigation array used in BuddyPress themes.
    288308 *
Note: See TracChangeset for help on using the changeset viewer.