This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

hnla revisions to pcwriter bp-wp-navbar plugin

By: a guest on Aug 10th, 2010  |  syntax: None  |  size: 5.53 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. $pageLinkDropdown = false; // set true for dropdown
  49. ?>
  50.  
  51. <?php if($current_blog->blog_id == '1') : ?>
  52.  
  53.  
  54. <!-- Community Drop Down -->
  55. <li
  56. <?php if (bp_is_page( BP_ACTIVITY_SLUG ) ||
  57. bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ||
  58. bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ||
  59. bp_is_page( BP_FORUMS_SLUG ) ||
  60. bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  61.  
  62. <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( '', 'buddypress' ) ?>"><?php _e( 'Community', 'buddypress' ) ?></a>
  63.  
  64. <ul>
  65.  
  66. <?php if ( bp_is_active( 'activity' ) ) : ?>
  67. <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  68. <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
  69. </li>
  70. <?php endif; ?>
  71.  
  72. <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
  73. <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
  74. </li>
  75.  
  76. <?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
  77. <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  78. <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Member Blogs', 'buddypress' ) ?>"><?php _e( 'Member Blogs', 'buddypress' ) ?></a>
  79. </li>
  80. <?php endif; ?>
  81.  
  82. <?php if ( bp_is_active( 'groups' ) ) : ?>
  83. <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
  84. <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
  85. </li>
  86.  
  87. <?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() ) : ?>
  88. <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  89. <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Group Forums', 'buddypress' ) ?>"><?php _e( 'Group Forums', 'buddypress' ) ?></a>
  90. </li>
  91. <?php endif; ?>
  92. <?php endif; ?>
  93.  
  94. <?php do_action( 'bp_nav_items' ); ?>
  95.  
  96. </ul>
  97.  
  98. </li>
  99. <?php if(!function_exists( 'wp_nav_menu' ) ): ?>
  100. <?php ### Don't show wp_list_pages if WP 3.0 use New wp_nav_menus instead ### ?>
  101. <?php if($pageLinkDropdown) : ?>
  102. <li><a href="/">Pages</a>
  103.   <ul>
  104. <?php endif; ?>
  105.  
  106.  <li>
  107.    <?php wp_list_pages( 'title_li=&depth=20&exclude=237,1133,1735,1844' ); ?>
  108.  </li>
  109.  
  110. <?php if($lpageLinkDropdown) : ?>
  111.  </ul>
  112. </li>
  113. <?php endif; ?>
  114. <?php endif; ?>
  115.  
  116. <?php ################# Add call to WP Nav Menus ############################## ?>
  117. <?php if ( function_exists( 'wp_nav_menu' ) ): ?>
  118. <?php if(has_nav_menu('bp_adminbar_pages1')): ?>
  119. <li><a href="<?php site_url() ?>">Pages</a>
  120.   <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages1')) ?>
  121. </li>
  122. <?php endif; ?>
  123.  
  124. <?php if(has_nav_menu('bp_adminbar_pages2')): ?>
  125. <li><a href="<?php site_url() ?>">Pages 2</a>
  126.   <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages2')) ?>
  127. </li>
  128. <?php endif; ?>
  129. <?php endif; // end check for wp 3.0 ?>
  130. <?php  ############# end WP 3.0 wp_nav_menus ###################### ?>
  131.  
  132. <?php endif; ?>
  133.  
  134. <?php
  135.  
  136. }
  137.  
  138. add_action( 'bp_adminbar_menus', 'pages', 15 )
  139.  
  140. ?>
clone this paste RAW Paste Data