Advertisement
Guest User

rev to pcwriter/hnla code

a guest
Aug 10th, 2010
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Plugin Name: Add All Nav Links to BP Adminbar (bp-wp-navbar)
  5. Requires at least: WordPress 2.9.2 / BuddyPress 1.2.3
  6. 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.)
  7. Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
  8. 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.
  9. Version: 0.1 (Initial release)
  10. Author: Patrick Cohen (pcwriter)
  11. Author URI: http://nowrecovery.com/members/admin/
  12.  
  13. Thanks and props to David Lewis, Chau kar, Jens Wedin, hnla and r-a-y for their contributions, for helping me learn basic stuff and helping to iron out the kinks in this code (whether they know it or not).
  14.  
  15. License : GPL2
  16. Copyright 2010 Patrick Cohen (email : info@nowrecovery.com)
  17.  
  18. This program is free software; you can redistribute it and/or modify
  19. it under the terms of the GNU General Public License, version 2, as
  20. published by the Free Software Foundation.
  21.  
  22. This program is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. GNU General Public License for more details.
  26.  
  27. You should have received a copy of the GNU General Public License
  28. along with this program; if not, write to the Free Software
  29. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  30. */
  31.  
  32. // Register WP 3.0 nav menus regions
  33. // Create regions for each user menu type
  34. if ( function_exists( 'register_nav_menus' ) ) {
  35. register_nav_menus( array(
  36. 'bp_adminbar_pages1' => __( 'Adminbar pages 1'),
  37. 'bp_adminbar_pages2' => __( 'Adminbar pages 2 ')
  38. ) );
  39. }
  40.  
  41.  
  42.  
  43.  
  44. // Begin 'pages' function
  45.  
  46. function pages(){
  47. global $current_blog;
  48. ?>
  49.  
  50. <?php if($current_blog->blog_id == '1') : ?>
  51.  
  52.  
  53. <!-- Community Drop Down -->
  54. <li
  55. <?php if (bp_is_page( BP_ACTIVITY_SLUG ) ||
  56. bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ||
  57. bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ||
  58. bp_is_page( BP_FORUMS_SLUG ) ||
  59. bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  60.  
  61. <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( '', 'buddypress' ) ?>"><?php _e( 'Community', 'buddypress' ) ?></a>
  62.  
  63. <ul>
  64.  
  65. <?php if ( bp_is_active( 'activity' ) ) : ?>
  66. <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  67. <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
  68. </li>
  69. <?php endif; ?>
  70.  
  71. <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
  72. <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
  73. </li>
  74.  
  75. <?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
  76. <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  77. <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Member Blogs', 'buddypress' ) ?>"><?php _e( 'Member Blogs', 'buddypress' ) ?></a>
  78. </li>
  79. <?php endif; ?>
  80.  
  81. <?php if ( bp_is_active( 'groups' ) ) : ?>
  82. <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
  83. <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
  84. </li>
  85.  
  86. <?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() ) : ?>
  87. <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  88. <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Group Forums', 'buddypress' ) ?>"><?php _e( 'Group Forums', 'buddypress' ) ?></a>
  89. </li>
  90. <?php endif; ?>
  91. <?php endif; ?>
  92.  
  93. <?php do_action( 'bp_nav_items' ); ?>
  94.  
  95. </ul>
  96.  
  97. </li>
  98. <?php if(!function_exists( 'wp_nav_menu' ) ): ?>
  99. <?php ### Don't show wp_list_pages if WP 3.0 use New wp_nav_menus instead ### ?>
  100.  
  101.  
  102. <li>
  103. <?php wp_list_pages( 'title_li=&depth=20&exclude=237,1133,1735,1844' ); ?>
  104. </li>
  105.  
  106.  
  107. <?php endif; ?>
  108.  
  109. <?php ################# Add call to WP Nav Menus ############################## ?>
  110. <?php if ( function_exists( 'wp_nav_menu' ) ): ?>
  111. <?php if(has_nav_menu('bp_adminbar_pages1')): ?>
  112. <li><a href="<?php site_url() ?>">Pages</a>
  113. <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages1')) ?>
  114. </li>
  115. <?php endif; ?>
  116.  
  117. <?php if(has_nav_menu('bp_adminbar_pages2')): ?>
  118. <li><a href="<?php site_url() ?>">Pages 2</a>
  119. <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages2')) ?>
  120. </li>
  121. <?php endif; ?>
  122. <?php endif; // end check for wp 3.0 ?>
  123. <?php ############# end WP 3.0 wp_nav_menus ###################### ?>
  124.  
  125. <?php endif; ?>
  126.  
  127. <?php
  128.  
  129. }
  130.  
  131. add_action( 'bp_adminbar_menus', 'pages', 15 )
  132.  
  133. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement