Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter("bp_search_form_type_select", "bpmag_remove_search_dropdown" );
- function bpmag_remove_search_dropdown($select_html){
- return '';
- }
- function new_excerpt_length($length) {
- return 30;
- }
- add_filter('excerpt_length', 'new_excerpt_length');
- remove_action( 'init', 'bp_core_action_search_site', 5 );//force buddypress to not process the search/redirect
- add_action( 'init', 'bp_buddydev_search', 10 );// custom handler for the search
- function bp_buddydev_search(){
- global $bp;
- if ( $bp->current_component == BP_SEARCH_SLUG )//if thids is search page
- bp_core_load_template( apply_filters( 'bp_core_template_search_template', 'search-single' ) );//load the single searh template
- }
- function ray_secondary_avatar_fix() {
- remove_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 );
- // add the following if you still want secondary avatars, but omitting the blog one
- function my_bp_dtheme_activity_secondary_avatars( $action, $activity ) {
- switch ( $activity->component ) {
- case 'groups' :
- case 'friends' :
- // Only insert avatar if one exists
- if ( $secondary_avatar = bp_get_activity_secondary_avatar() ) {
- $reverse_content = strrev( $action );
- $position = strpos( $reverse_content, 'a<' );
- $action = substr_replace( $action, $secondary_avatar, -$position - 2, 0 );
- }
- break;
- }
- return $action;
- }
- add_filter( 'bp_get_activity_action_pre_meta', 'my_bp_dtheme_activity_secondary_avatars', 10, 2 );
- }
- add_action('init', 'ray_secondary_avatar_fix');
- //show the search results for member*/
- function bpmag_show_member_search(){
- ?>
- <div class="memberss-search-result search-result">
- <h2 class="content-title"><?php _e("Members Results","bpmag");?></h2>
- <?php locate_template( array( 'members/members-loop.php' ), true ) ; ?>
- <?php global $members_template;
- if($members_template->total_member_count>1):?>
- <a href="<?php echo bp_get_root_domain().'/'.BP_MEMBERS_SLUG.'/?s='.$_REQUEST['s']?>" ><?php _e(sprintf("View all %d matched Members",$members_template->total_member_count),"bpmag");?></a>
- <?php endif; ?>
- </div>
- <?php
- }
- //Hook Member results to search page
- add_action("advance-search","bpmag_show_member_search",10); //the priority defines where in page this result will show up(the order of member search in other searchs)
- function bpmag_show_groups_search(){
- ?>
- <div class="groups-search-result search-result">
- <h2 class="content-title"><?php _e("Group Search","bpmag");?></h2>
- <?php locate_template( array('groups/groups-loop.php' ), true ) ; ?>
- <a href="<?php echo bp_get_root_domain().'/'.BP_GROUPS_SLUG.'/?s='.$_REQUEST['s']?>" ><?php _e("View All matched Groups","bpmag");?></a>
- </div>
- <?php
- //endif;
- }
- //Hook Groups results to search page
- if(bp_is_active( 'groups' ))
- add_action("advance-search","bpmag_show_groups_search",10);
- /**
- *
- * Show blog posts in search
- */
- function bpmag_show_site_blog_search(){
- ?>
- <div class="blog-search-result search-result">
- <h2 class="content-title"><?php _e("Blog Posts","bpmag");?></h2>
- <?php locate_template( array( 'search-loop.php' ), true ) ; ?>
- <a href="<?php echo bp_get_root_domain().'/?s='.$_REQUEST['s']?>" ><?php _e("View All matched Posts","bpmag");?></a>
- </div>
- <?php
- }
- //Hook Blog Post results to search page
- add_action("advance-search","bpmag_show_site_blog_search",10);
- function bpmag_show_global_forum_search(){
- ?>
- <div>
- <h2>Forum Discussion Search</h2>
- <?php locate_template( array( 'gf/search.php' ), true ) ; ?>
- <a href="<?php echo bp_get_root_domain().'/'.GF_SLUG.'/?gfs='.$_REQUEST['search-terms']?>" ><?php _e("View All matched topics","bpmag");?></a>
- </div>
- <?php
- }
- //Hook Blog Post results to search page
- add_action("advance-search","bpmag_show_global_forum_search",33);
- //show blogs search result
- function bpmag_show_blogs_search(){
- ?>
- <div class="blogs-search-result search-result">
- <h2 class="content-title"><?php _e("Sites Search","bpmag");?></h2>
- <?php locate_template( array( 'blogs/blogs-loop.php' ), true ) ; ?>
- <a href="<?php echo bp_get_root_domain().'/'.BP_BLOGS_SLUG.'/?s='.$_REQUEST['s']?>" ><?php _e("View All matched Sites","bpmag");?></a>
- </div>
- <?php
- }
- //Hook Blogs results to search page if blogs comonent is active
- if(bp_is_active( 'blogs' ))
- add_action("advance-search","bpmag_show_blogs_search",10);
- //modify the query string with the search term
- function bpmag_global_search_qs($qs){
- if(bpmag_is_advance_search())
- return "search_terms=".$_REQUEST['s'];
- return $qs;
- }
- function bpmag_is_advance_search(){
- global $bp;
- if($bp->current_component == BP_SEARCH_SLUG)
- return true;
- return false;
- }
- add_filter("bp_ajax_querystring","bpmag_global_search_qs",200);
- ?>
- <?php
- /** all the credit to @apeatling, the code below is a modified version of apeatling's code for function bp_dtheme_post_update in bp-default/_inc/ajax.php */
- //let us remove the default handler for activity posting
- remove_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' );
- //add our own handler for activity posting
- add_action( 'wp_ajax_post_update', 'bp_mytheme_post_update' );
- /* AJAX update posting */
- function bp_mytheme_post_update() {
- global $bp;
- /* Check the nonce */
- check_admin_referer( 'post_update', '_wpnonce_post_update' );
- if ( !is_user_logged_in() ) {
- echo '-1';
- return false;
- }
- if ( empty( $_POST['content'] ) ) {
- echo '-1<div id="message"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>';
- return false;
- }
- if ( empty( $_POST['object'] ) && function_exists( 'bp_activity_post_update' ) ) {
- //this is what I have changed
- if(!bp_is_home()&&bp_is_member())
- $content="@". bp_get_displayed_user_username()." ".$_POST['content'];
- else
- $content=$_POST['content'];
- $activity_id = bp_activity_post_update( array( 'content' => $content ) );
- //end of my changes
- } elseif ( $_POST['object'] == 'groups' ) {
- if ( !empty( $_POST['item_id'] ) &&function_exists( 'groups_post_update' ) )
- $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
- } else
- $activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] );
- if ( !$activity_id ) {
- echo '-1<div id="message"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>';
- return false;
- }
- if ( bp_has_activities ( 'include=' . $activity_id ) ) : ?>
- <?php while ( bp_activities() ) : bp_the_activity(); ?>
- <?php locate_template( array( 'activity/entry.php' ), true ) ?>
- <?php endwhile; ?>
- <?php endif;
- }
- register_sidebars( 1,
- array(
- 'name' => 'sidebarforum',
- 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle">',
- 'after_title' => '</h3>'
- )
- );
- register_sidebar(
- array(
- 'name' => __('sidebar-member-center'),
- 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle">',
- 'after_title' => '</h3>'
- )
- );
- register_sidebar(
- array(
- 'name' => __('sidebar-sign-up'),
- 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle">',
- 'after_title' => '</h3>'
- )
- );
- register_sidebar(
- array(
- 'name' => __('sidebarfeatures'),
- 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle">',
- 'after_title' => '</h3>'
- )
- );
- register_sidebar(
- array(
- 'name' => __('site-features'),
- 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle">',
- 'after_title' => '</h3>'
- )
- );
- register_sidebar(
- array(
- 'name' => __('blog-school'),
- 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle">',
- 'after_title' => '</h3>'
- )
- );
- register_sidebar(
- array(
- 'name' => __('tutorials'),
- 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle">',
- 'after_title' => '</h3>'
- )
- );
- //remove @mentions
- // removes @mention links in updates, forum posts, etc.
- remove_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' );
- remove_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
- remove_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
- remove_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
- remove_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
- remove_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' );
- // remove @mention email notifications
- remove_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 );
- remove_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 );
- function ray_remove_mention_nav() {
- global $bp;
- bp_core_remove_subnav_item( $bp->activity->slug, 'mentions' );
- }
- add_action( 'init', 'ray_remove_mention_nav' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement