Skip to:
Content

BuddyPress.org

Changeset 3631


Ignore:
Timestamp:
12/31/2010 05:49:36 PM (14 years ago)
Author:
djpaul
Message:

Hide forum directory from main nav if disabled by admin. Fixes #2541, props boonebgorges

Location:
trunk
Files:
4 edited

Legend:

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

    r3627 r3631  
    985985 * Only show the search form if there are available objects to search for.
    986986 *
    987  * @global array $bp
    988987 * @uses function_exists
    989988 * @uses is_multisite()
     
    991990 */
    992991function bp_search_form_enabled() {
    993     global $bp;
    994 
    995992    if ( bp_is_active( 'xprofile' )
    996993         || bp_is_active( 'groups' )
    997994         || ( bp_is_active( 'blogs' ) && is_multisite() )
    998          || ( function_exists( 'bp_forums_setup' ) && !(int)$bp->site_options['bp-disable-forum-directory'] )
    999         ) {
     995         || ( bp_is_active( 'forums' ) && !bp_forum_directory_is_disabled() )
     996    ) {
    1000997        $search_enabled = true;
    1001998    } else {
     
    10301027        $options['groups'] = __( 'Groups', 'buddypress' );
    10311028
    1032     if ( function_exists( 'bp_forums_is_installed_correctly' ) && bp_forums_is_installed_correctly() && !isset( $bp->site_options['bp-disable-forum-directory'] ) )
     1029    if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && !bp_forum_directory_is_disabled() )
    10331030        $options['forums'] = __( 'Forums', 'buddypress' );
    10341031
  • trunk/bp-forums.php

    r3627 r3631  
    5151}
    5252
     53/**
     54 * Convenience function to determine if the forum directory has been disabled
     55 * by the site admin.
     56 *
     57 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     58 * @return bool True if forum is disabled
     59 * @since 1.3
     60 */
     61function bp_forum_directory_is_disabled() {
     62    global $bp;
     63
     64    return !empty( $bp->site_options['bp-disable-forum-directory'] );
     65}
     66
    5367function bp_forums_directory_forums_setup() {
    5468    global $bp;
    5569
    5670    if ( $bp->current_component == $bp->forums->slug ) {
    57         if ( (int) $bp->site_options['bp-disable-forum-directory'] || !bp_is_active( 'groups' ) )
     71        if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) )
    5872            return false;
    5973
  • trunk/bp-themes/bp-default/functions.php

    r3626 r3631  
    468468    add_action( 'admin_notices', 'bp_dtheme_show_notice' );
    469469
     470if ( !function_exists( 'bp_dtheme_main_nav' ) ) :
    470471/**
    471472 * wp_nav_menu() callback from the main navigation in header.php
     
    478479 * @since 1.3
    479480 */
    480 function bp_dtheme_main_nav( $args ) { ?>
     481function bp_dtheme_main_nav( $args ) {
     482    global $bp;
     483
     484    $pages_args = array(
     485        'title_li' => '',
     486        'depth' => '0',
     487        'exclude' => bp_dtheme_page_on_front()
     488    );
     489
     490    if ( bp_forum_directory_is_disabled() ) {
     491        if ( !empty( $pages_args['exclude'] ) )
     492                $pages_args['exclude'] .= ',';
     493
     494        $pages_args['exclude'] .= $bp->pages->forums->id;
     495    }
     496?>
    481497    <ul id="nav">
    482498        <li<?php if ( is_front_page() ) : ?> class="selected"<?php endif; ?>>
     
    484500        </li>
    485501
    486         <?php wp_list_pages( 'title_li=&depth=0&exclude=' . bp_dtheme_page_on_front() ); ?>
    487         <?php do_action( 'bp_nav_items' ); ?>
     502        <?php wp_list_pages( $pages_args ) ?>
     503        <?php do_action( 'bp_nav_items' ) ?>
    488504    </ul><!-- #nav -->
    489505<?php
    490506}
     507endif;
    491508
    492509/**
  • trunk/bp-themes/bp-default/groups/single/forum/topic.php

    r3537 r3631  
    1919        <div id="topic-meta">
    2020            <h3><?php bp_the_topic_title() ?> (<?php bp_the_topic_total_post_count() ?>)</h3>
    21             <a class="button" href="<?php bp_forum_permalink() ?>/">&larr; <?php _e( 'Group Forum', 'buddypress' ) ?></a> &nbsp; <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a>
     21            <a class="button" href="<?php bp_forum_permalink() ?>/">&larr; <?php _e( 'Group Forum', 'buddypress' ) ?></a> &nbsp; <?php if ( !bp_forum_directory_is_disabled() ) : ?><a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a><?php endif; ?>
    2222
    2323            <div class="admin-links">
Note: See TracChangeset for help on using the changeset viewer.