Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Add All Nav Links to BP Adminbar (bp-wp-navbar)
- Requires at least: WordPress 2.9.2 / BuddyPress 1.2.3
- Tested up to: WordPress 3.0 / BuddyPress 1.2.5.2 (Should work anyway. Be sure to read the readme file for more on this.)
- Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
- Description: This plugin aggregates all Buddypress directory and Wordpress page links into the BP Adminbar. All BP pages are collected in a Community dropdown, and all WP pages appear in dropdowns that respect whatever page order you have set in your WP backend.
- Version: 1.1 (Initial release)
- Author: Patrick Cohen (pcwriter)
- Author URI: http://nowrecovery.com/members/admin/
- Thanks and props to hnla for invaluable collaboration and tutoring on this plugin; to David Lewis, Chau kar, Jens Wedin, and r-a-y for some great contributions; and to all for helping me learn basic stuff and iron out the kinks in this code (whether they know it or not).
- License : GPL2
- Copyright 2010 Patrick Cohen (email : [email protected])
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- /*-------------------------- USER CONFIG OPTIONS --------------------------*/
- // Configure wp_list_pages nav as horizontal(false) or vertical dropdown(true)
- $pageLinkDropdown = true; // set true for dropdown
- // Configure top level Nav bar label (wp_list_pages as vertical dropdown)
- $wpListPagesLabel = 'Pages';
- // Configure label for 'Community' links default = 'Community'
- $bpCommunityLinks = 'Community';
- // Configure labels for wp_nav_menu dropdowns
- $adminbarPages1 = 'Pages';
- $adminbarPages2 = 'pages 2';
- // hide the main site navigation - default = false(show) set to true to hide
- $hideMainNav = false; // set true to hide main site links
- /*-------------------------- END USER CONFIG -----------------------------*/
- // Register WP 3.0 nav menus regions
- // Create regions for each user menu type
- if ( function_exists( 'register_nav_menus' ) ) {
- register_nav_menus( array(
- 'bp_adminbar_pages1' => __( 'Adminbar pages 1'),
- 'bp_adminbar_pages2' => __( 'Adminbar pages 2 ')
- ) );
- }
- // Begin 'pages' function
- function pages(){
- global $current_blog, $pageLinkDropdown, $wpListPagesLabel, $bpCommunityLinks, $adminbarPages1,
- $adminbarPages2 ;
- ?>
- <?php if($current_blog->blog_id == '1') : ?>
- <!-- Community Drop Down -->
- <li
- <?php if (bp_is_page( BP_ACTIVITY_SLUG ) ||
- bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ||
- bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ||
- bp_is_page( BP_FORUMS_SLUG ) ||
- bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
- <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( '', 'buddypress' ) ?>"><?php _e( $bpCommunityLinks, 'buddypress' ) ?></a>
- <ul>
- <?php if ( bp_is_active( 'activity' ) ) : ?>
- <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
- <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
- </li>
- <?php endif; ?>
- <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
- <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
- </li>
- <?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
- <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
- <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Member Blogs', 'buddypress' ) ?>"><?php _e( 'Member Blogs', 'buddypress' ) ?></a>
- </li>
- <?php endif; ?>
- <?php if ( bp_is_active( 'groups' ) ) : ?>
- <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
- <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
- </li>
- <?php if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) get_site_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
- <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
- <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Group Forums', 'buddypress' ) ?>"><?php _e( 'Group Forums', 'buddypress' ) ?></a>
- </li>
- <?php endif; ?>
- <?php endif; ?>
- <?php do_action( 'bp_nav_items' ); ?>
- </ul>
- </li>
- <?php if(!function_exists( 'wp_nav_menu' ) ): ?>
- <?php ### Don't show wp_list_pages if WP 3.0 use New wp_nav_menus instead ### ?>
- <?php if($pageLinkDropdown) : ?>
- <li><a href="/"><?php echo $wpListPagesLabel; ?></a>
- <ul>
- <?php endif; ?>
- <li>
- <?php wp_list_pages( 'title_li=&depth=20&exclude=' ); ?>
- </li>
- <?php if($pageLinkDropdown) : ?>
- </ul>
- </li>
- <?php endif; ?>
- <?php endif; ?>
- <?php ##################### Add call to WP Nav Menus ####################### ?>
- <?php if ( function_exists( 'wp_nav_menu' ) ): ?>
- <?php if(has_nav_menu('bp_adminbar_pages1')): ?>
- <li><a href="<?php site_url() ?>"><?php echo $adminbarPages1; ?></a>
- <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages1')) ?>
- </li>
- <?php endif; ?>
- <?php if(has_nav_menu('bp_adminbar_pages2')): ?>
- <li><a href="<?php site_url() ?>"><?php echo $adminbarPages2; ?></a>
- <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages2')) ?>
- </li>
- <?php endif; ?>
- <?php endif; // end check for wp 3.0 ?>
- <?php ################# end WP 3.0 wp_nav_menus ########################### ?>
- <?php endif; ?>
- <?php
- }
- add_action( 'bp_adminbar_menus', 'pages', 15 );
- if ( $hideMainNav ):
- function hide_main_nav() { ?>
- <style type="text/css">
- /*<![CDATA[*/
- /* bp-wp-navbar - hide main site navigation */
- ul#nav {display:none;}
- /*]]>*/
- </style>
- <?php }
- add_action('wp_head', 'hide_main_nav');
- endif;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement