WordPress.org

Making WordPress.org

Changeset 977


Ignore:
Timestamp:
11/12/2014 08:36:24 PM (6 years ago)
Author:
djpaul
Message:

BuddyPress.org/bbPress.org: add support for displaying a custom menu in replacement of the main navigation.

This is a stop-gap measure to allow i18n BuddyPress sites, like es.buddypress.org, translate the labels and URLs in the main navigation.
Right now, these bits are hardcoded in English and stick out like a sore thumb on a i18n site where someone has written lots of native language content.

Fixes https://buddypress.trac.wordpress.org/ticket/5974

Location:
sites/trunk/buddypress.org/public_html/wp-content/themes/bb-base
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/buddypress.org/public_html/wp-content/themes/bb-base/functions.php

    r865 r977  
    499499}
    500500add_action( 'bbp_template_redirect', 'bb_base_recount_current_thing' );
     501
     502function bb_base_register_menus() {
     503    register_nav_menu( 'header-nav-menu', 'Main nav bar' );
     504}
     505add_action( 'init', 'bb_base_register_menus' );
  • sites/trunk/buddypress.org/public_html/wp-content/themes/bb-base/header-nav.php

    r456 r977  
    1 <ul id="nav" class="menu">
    2     <li <?php if ( is_page( 'about'    ) ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'about'   ); ?>">About</a></li>
    3     <li <?php if ( is_page( 'plugins'  ) ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'plugins' ); ?>">Plugins</a></li>
    4     <li <?php if ( is_page( 'themes'   ) ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'themes'  ); ?>">Themes</a></li>
    5     <li><a href="<?php echo esc_url( '//codex.' . parse_url( home_url(), PHP_URL_HOST ) . '/' ); ?>">Documentation</a></li>
    6     <li <?php if ( is_post_type_archive( 'post' ) || is_singular( 'post' ) || is_date() || is_tag() || is_category() || is_home() ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'blog' ); ?>">Blog</a></li>
    7     <?php if ( function_exists( 'is_bbpress' ) ) : ?><li <?php if ( is_bbpress() ) : ?>class="current"<?php endif; ?>><a href="<?php bbp_forums_url(); ?>">Support</a></li><?php endif; ?>
    8     <li class="download<?php if ( is_page( 'download' ) ) : ?> current<?php endif; ?>"><a href="<?php echo home_url( 'download' ); ?>">Download</a></li>
    9 </ul>
     1<?php if ( ! has_nav_menu( 'header-nav-menu' ) ) : ?>
     2    <ul id="nav" class="menu">
     3        <li <?php if ( is_page( 'about'    ) ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'about'   ); ?>">About</a></li>
     4        <li <?php if ( is_page( 'plugins'  ) ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'plugins' ); ?>">Plugins</a></li>
     5        <li <?php if ( is_page( 'themes'   ) ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'themes'  ); ?>">Themes</a></li>
     6        <li><a href="<?php echo esc_url( '//codex.' . parse_url( home_url(), PHP_URL_HOST ) . '/' ); ?>">Documentation</a></li>
     7        <li <?php if ( is_post_type_archive( 'post' ) || is_singular( 'post' ) || is_date() || is_tag() || is_category() || is_home() ) : ?>class="current"<?php endif; ?>><a href="<?php echo home_url( 'blog' ); ?>">Blog</a></li>
     8        <?php if ( function_exists( 'is_bbpress' ) ) : ?><li <?php if ( is_bbpress() ) : ?>class="current"<?php endif; ?>><a href="<?php bbp_forums_url(); ?>">Support</a></li><?php endif; ?>
     9        <li class="download<?php if ( is_page( 'download' ) ) : ?> current<?php endif; ?>"><a href="<?php echo home_url( 'download' ); ?>">Download</a></li>
     10    </ul>
     11<?php else: ?>
     12    <?php wp_nav_menu( array(
     13            'container'      => '',
     14            'menu_class'     => 'menu',
     15            'menu_id'        => 'nav',
     16            'theme_location' => 'header-nav-menu',
     17        ) ); ?>
     18<?php endif; ?>
  • sites/trunk/buddypress.org/public_html/wp-content/themes/bb-base/style-bbpress.css

    r703 r977  
    3535
    3636#nav li.current a,
     37#nav li.current-menu-item a,
    3738#nav li a:hover,
    3839.button:hover {
     
    7475
    7576#nav li.current a,
     77#nav li.current-menu-item a,
    7678#nav li a:active,
    7779.button:active {
  • sites/trunk/buddypress.org/public_html/wp-content/themes/bb-base/style-buddypress.css

    r703 r977  
    6262}
    6363
     64#nav li.current-menu-item a,
    6465#nav li.current a,
    6566#nav li a:active {
Note: See TracChangeset for help on using the changeset viewer.