Conditional tags for BuddyPress
-
I always find the conditional tags for WP very useful, and as I can’t find an equivalent for the BuddyPress pages I’ve started a plugin to fill the gap. Does this code seem sane?
<?php
// $identifier can be either the group name, ID or slug
if ( !function_exists('is_group') ) :
function is_group( $identifier = false ) {
global $bp;
// No $bp? Nothing doing then.
if ( ! $bp )
return false;
// Not in the groups component? Definitely not a group then
if ( $bp->current_component != 'groups' )
return false;
// If no identifier was passed then we've confirmed as
// much as we need to
if ( $identifier === false )
return true;
// If the identifier passed == the current item, then the
// identifier must have been the group slug
if ( $identifier == $bp->current_item )
return true;
// Now check the ID
if ( $identifier == $bp->groups->current_group->id )
return true;
// Lastly, check the name
if ( $identifier == $bp->groups->current_group->name )
return true;
// We were passed an identifier, but it doesn't match
// slug, ID or name, so we must return false.
return false;
}
endif;
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Conditional tags for BuddyPress’ is closed to new replies.