Want more features on Pastebin? Sign Up, it's FREE!
Guest

rev to pcwriter/hnla code

By: a guest on Aug 11th, 2010  |  syntax: None  |  size: 7.89 KB  |  views: 92  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
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: 1.1 (Initial release)
  10. Author: Patrick Cohen (pcwriter)
  11. Author URI: http://nowrecovery.com/members/admin/
  12.  
  13. 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).
  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. /*-------------------------- USER CONFIG OPTIONS --------------------------*/
  33.  
  34. // Configure wp_list_pages nav as horizontal(false) or vertical dropdown(true)
  35.  $pageLinkDropdown = false; // set true for dropdown
  36.  
  37. // Configure top level Nav bar label (wp_list_pages as vertical dropdown)
  38.  $wpListPagesLabel = 'Pages';
  39.  
  40. // Configure label for 'Community' links default = 'Community'
  41.  $bpCommunityLinks = 'Community';
  42.  
  43. // Configure labels for wp_nav_menu dropdowns
  44.  $adminbarPages1 = 'Pages';
  45.  $adminbarPages2 = 'pages 2';
  46.  
  47. // hide the main site navigation - default = true(hide) set to true to hide
  48.  $hideMainNav = true; // set false to show main site links
  49.  
  50.  // hide the site name-logo - default = true(hide) set to false to show
  51.  $hideSiteName = true; // set false to show site name
  52.  
  53.  // hide the login-signup links - default = false(show) set to true to hide
  54.  $hideLoginStuff = false; // set true to hide login links
  55.  
  56.  // hide the visit-random menu - default = false(show) set to true to hide
  57.  $hideRandomMenu = false; // set to true to hide visit menu
  58.  
  59. /*--------------------------  END USER CONFIG -----------------------------*/
  60.  
  61. // Register WP 3.0 nav menus regions
  62. // Create regions for each user menu type
  63. if ( function_exists( 'register_nav_menus' ) ) {
  64.         register_nav_menus( array(
  65.           'bp_adminbar_pages1' => __( 'Adminbar pages 1'),
  66.     'bp_adminbar_pages2' => __( 'Adminbar pages 2 ')
  67.         ) );
  68.     }
  69.  
  70.  
  71. // Begin 'pages' function
  72.  
  73. function pages(){
  74. global $current_blog, $pageLinkDropdown, $wpListPagesLabel, $bpCommunityLinks, $adminbarPages1,
  75. $adminbarPages2 ;
  76.  
  77. ?>
  78.  
  79. <?php if($current_blog->blog_id == '1') : ?>
  80.  
  81.  
  82. <!-- Community Drop Down -->
  83. <li
  84. <?php if (bp_is_page( BP_ACTIVITY_SLUG ) ||
  85. bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ||
  86. bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ||
  87. bp_is_page( BP_FORUMS_SLUG ) ||
  88. bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  89.  
  90. <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( '', 'buddypress' ) ?>"><?php _e( $bpCommunityLinks, 'buddypress' ) ?></a>
  91.  
  92. <ul>
  93.  
  94. <?php if ( bp_is_active( 'activity' ) ) : ?>
  95. <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  96. <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
  97. </li>
  98. <?php endif; ?>
  99.  
  100. <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
  101. <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
  102. </li>
  103.  
  104. <?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
  105. <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  106. <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Member Blogs', 'buddypress' ) ?>"><?php _e( 'Member Blogs', 'buddypress' ) ?></a>
  107. </li>
  108. <?php endif; ?>
  109.  
  110. <?php if ( bp_is_active( 'groups' ) ) : ?>
  111. <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
  112. <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
  113. </li>
  114.  
  115. <?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() ) : ?>
  116. <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  117. <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Group Forums', 'buddypress' ) ?>"><?php _e( 'Group Forums', 'buddypress' ) ?></a>
  118. </li>
  119. <?php endif; ?>
  120. <?php endif; ?>
  121.  
  122. <?php do_action( 'bp_nav_items' ); ?>
  123.  
  124. </ul>
  125.  
  126. </li>
  127. <?php if(!function_exists( 'wp_nav_menu' ) ): ?>
  128. <?php ### Don't show wp_list_pages if WP 3.0 use New wp_nav_menus instead ### ?>
  129. <?php if($pageLinkDropdown) : ?>
  130. <li><a href="/"><?php echo $wpListPagesLabel; ?></a>
  131.   <ul>
  132. <?php endif; ?>
  133.  
  134.  <li>
  135.    <?php wp_list_pages( 'title_li=&depth=20&exclude=' ); ?>
  136.  </li>
  137.  
  138. <?php if($pageLinkDropdown) : ?>
  139.  </ul>
  140. </li>
  141. <?php endif; ?>
  142. <?php endif; ?>
  143.  
  144. <?php ##################### Add call to WP Nav Menus ####################### ?>
  145. <?php if ( function_exists( 'wp_nav_menu' ) ): ?>
  146. <?php if(has_nav_menu('bp_adminbar_pages1')): ?>
  147. <li><a href="<?php site_url() ?>"><?php echo $adminbarPages1; ?></a>
  148.   <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages1')) ?>
  149. </li>
  150. <?php endif; ?>
  151.  
  152. <?php if(has_nav_menu('bp_adminbar_pages2')): ?>
  153. <li><a href="<?php site_url() ?>"><?php echo $adminbarPages2; ?></a>
  154.   <?php wp_nav_menu(array('sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => '', 'theme_location' => 'bp_adminbar_pages2')) ?>
  155. </li>
  156. <?php endif; ?>
  157.  
  158. <?php endif; // end check for wp 3.0 ?>
  159. <?php  ################# end WP 3.0 wp_nav_menus ########################### ?>
  160.  
  161. <?php endif; ?>
  162.  
  163. <?php
  164. }
  165.  
  166. add_action( 'bp_adminbar_menus', 'pages', 15 );
  167.  
  168. if ( $hideMainNav ):
  169. function hide_main_nav() { ?>
  170. <style type="text/css">
  171.  /*<![CDATA[*/
  172.  /* bp-wp-navbar - hide main site navigation */
  173.  ul#nav {display:none;}
  174.  /*]]>*/
  175. </style>
  176. <?php }
  177.  add_action('wp_head', 'hide_main_nav');
  178. endif;
  179.  
  180. if ( $hideSiteName ):
  181. function hide_site_name() { ?>
  182. <style type="text/css">
  183.  /*<![CDATA[*/
  184.  /* bp-wp-navbar - hide site name in navbar */
  185.  #admin-bar-logo {display:none;}
  186.  /*]]>*/
  187. </style>
  188. <?php }
  189.  add_action('wp_head', 'hide_site_name');
  190. endif;
  191.  
  192. if ( $hideLoginStuff ):
  193. function hide_login_stuff() { ?>
  194. <style type="text/css">
  195.  /*<![CDATA[*/
  196.  /* bp-wp-navbar - hide login links in navbar */
  197.  #wp-admin-bar li.no-arrow a {display:none;}
  198.  /*]]>*/
  199. </style>
  200. <?php }
  201.  add_action('wp_head', 'hide_login_stuff');
  202. endif;
  203.  
  204. if ( $hideRandomMenu ):
  205. function hide_random_menu() { ?>
  206. <style type="text/css">
  207.  /*<![CDATA[*/
  208.  /* bp-wp-navbar - hide login links in navbar */
  209.  #wp-admin-bar ul li.align-right {display:none;}
  210.  /*]]>*/
  211. </style>
  212. <?php }
  213.  add_action('wp_head', 'hide_random_menu');
  214. endif;
  215. ?>
clone this paste RAW Paste Data