Advertisement
Guest User

buddypress.php

a guest
Aug 30th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.62 KB | None | 0 0
  1. <?php
  2. // http://codex.buddypress.org/extending-buddypress/bp-custom-php/
  3. // Removing the links automatically created in a member's profile
  4. add_action( 'bp_init', 'firmasite_remove_xprofile_links' );
  5. function firmasite_remove_xprofile_links() {
  6.     remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
  7. }
  8.  
  9.  
  10. add_action( 'after_setup_theme', "firmasite_social_buddypress_setup");
  11. function firmasite_social_buddypress_setup() {
  12.     // bp 1.7+
  13.     add_theme_support( 'buddypress' );
  14.  
  15.     // Load the AJAX functions for the theme
  16.     require( get_template_directory() . '/assets/_inc/ajax.php' );
  17.  
  18.     if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
  19.         // Register buttons for the relevant component templates
  20.         // Friends button
  21.         if ( bp_is_active( 'friends' ) )
  22.             add_action( 'bp_member_header_actions',    'bp_add_friend_button',           5 );
  23.  
  24.         // Activity button
  25.         if ( bp_is_active( 'activity' ) )
  26.             add_action( 'bp_member_header_actions',    'bp_send_public_message_button',  20 );
  27.  
  28.         // Messages button
  29.         if ( bp_is_active( 'messages' ) )
  30.             add_action( 'bp_member_header_actions',    'bp_send_private_message_button', 20 );
  31.  
  32.         // Group buttons
  33.         if ( bp_is_active( 'groups' ) ) {
  34.             add_action( 'bp_group_header_actions',     'bp_group_join_button',           5 );
  35.             add_action( 'bp_group_header_actions',     'bp_group_new_topic_button',      20 );
  36.             add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
  37.         }
  38.  
  39.         // Blog button
  40.         if ( bp_is_active( 'blogs' ) )
  41.             add_action( 'bp_directory_blogs_actions',  'bp_blogs_visit_blog_button' );
  42.     }
  43.  
  44.     /** Notices ***********************************************************/
  45.     if ( bp_is_active( 'messages' ) ) {
  46.         add_action( 'wp_footer', "firmasite_sitewide_notices", 9999 );
  47.     }
  48.    
  49. }
  50.  
  51. function firmasite_sitewide_notices() {
  52.         // Do not show notices if user is not logged in
  53.         if ( ! is_user_logged_in() )
  54.             return;
  55.  
  56.         // add a class to determine if the admin bar is on or not
  57.         $class = did_action( 'admin_bar_menu' ) ? 'admin-bar-on' : 'admin-bar-off';
  58.  
  59.         echo '<div id="sitewide-notice" class="' . $class . '">';
  60.         firmasite_bp_message_get_notices();
  61.         echo '</div>';
  62. }
  63.  
  64. function firmasite_bp_message_get_notices() {
  65.     global $userdata;
  66.  
  67.     $notice = BP_Messages_Notice::get_active();
  68.  
  69.     if ( empty( $notice ) )
  70.         return false;
  71.  
  72.     $closed_notices = bp_get_user_meta( $userdata->ID, 'closed_notices', true );
  73.  
  74.     if ( !$closed_notices )
  75.         $closed_notices = array();
  76.  
  77.     if ( is_array($closed_notices) ) {
  78.         if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) {
  79.             ?>
  80.         <div id="message-<?php echo $notice->id ?>" class="info notice modal fade" rel="n-<?php echo $notice->id ?>" tabindex="-1" role="dialog" aria-hidden="false">
  81.           <div class="modal-dialog">
  82.             <div class="modal-content">
  83.               <div class="modal-header">
  84.                 <h3 class="modal-title"><?php echo stripslashes( wp_filter_kses( $notice->subject ) ) ?></h3>
  85.               </div>
  86.               <div class="modal-body">
  87.                 <p><?php echo stripslashes( wp_filter_kses( $notice->message) ) ?></p>
  88.               </div>              
  89.               <div class="modal-footer">
  90.                 <a href="#" id="close-notice" class="btn btn-primary" data-dismiss="modal" aria-hidden="true"><?php _e( 'Close', "firmasite" ) ?></a>
  91.               </div>
  92.             </div><!-- /.modal-content -->
  93.           </div><!-- /.modal-dialog -->
  94.         </div>
  95.             <script>
  96.             jQuery(document).ready(function() {
  97.                 jQuery('#message-<?php echo $notice->id ?>').modal('show');
  98.                 jQuery("#message-<?php echo $notice->id ?> #close-notice").click(function(){ jQuery('#message-<?php echo $notice->id ?>').modal('hide'); });
  99.             });
  100.             </script>
  101.             <?php
  102.         }
  103.     }
  104. }
  105.  
  106.  
  107. add_action( 'wp_enqueue_scripts', "firmasite_social_buddypress_scripts");
  108. function firmasite_social_buddypress_scripts() {
  109.  
  110.     // Enqueue the global JS - Ajax will not work without it
  111.     wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/assets/_inc/global.js', array( 'jquery' ), bp_get_version() );
  112.  
  113.     // Add words that we need to use in JS to the end of the page so they can be translated and still used.
  114.     $params = array(
  115.         'my_favs'           => __( 'My Favorites', "firmasite" ),
  116.         'accepted'          => __( 'Accepted', "firmasite" ),
  117.         'rejected'          => __( 'Rejected', "firmasite" ),
  118.         'show_all_comments' => __( 'Show all comments for this thread', "firmasite" ),
  119.         'show_all'          => __( 'Show all', "firmasite" ),
  120.         'comments'          => __( 'comments', "firmasite" ),
  121.         'close'             => __( 'Close', "firmasite" ),
  122.         'view'              => __( 'View', "firmasite" ),
  123.         'mark_as_fav'       => __( 'Favorite', "firmasite" ),
  124.         'remove_fav'        => __( 'Remove Favorite', "firmasite" )
  125.     );
  126.     wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params );
  127. }
  128.  
  129.  
  130. add_filter('bp_members_signup_error_message', "firmasite_bp_members_signup_error_message");
  131. function firmasite_bp_members_signup_error_message($string){
  132.     return '<div class="alert alert-error">' . $string . '</div>';
  133. }
  134.  
  135.  
  136. add_filter( 'bp_get_the_profile_field_options_checkbox', 'firmasite_customize_bp_get_the_profile_field_options_checkbox',10,1);
  137. function firmasite_customize_bp_get_the_profile_field_options_checkbox($html){
  138.     return '<div class="checkbox">' . $html . '</div>';
  139. }
  140.  
  141. add_filter( 'bp_get_the_profile_field_options_radio', 'firmasite_customize_bp_get_the_profile_field_options_radio',10,1);
  142. function firmasite_customize_bp_get_the_profile_field_options_radio($html){
  143.     return '<div class="radio">' . $html . '</div>';
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement