Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.63 KB | None | 0 0
  1. <?php
  2. add_filter("bp_search_form_type_select", "bpmag_remove_search_dropdown" );
  3. function bpmag_remove_search_dropdown($select_html){
  4. return '';
  5. }
  6.  
  7. function new_excerpt_length($length) {
  8. return 30;
  9. }
  10. add_filter('excerpt_length', 'new_excerpt_length');
  11.  
  12.  
  13. remove_action( 'init', 'bp_core_action_search_site', 5 );//force buddypress to not process the search/redirect
  14. add_action( 'init', 'bp_buddydev_search', 10 );// custom handler for the search
  15.  
  16. function bp_buddydev_search(){
  17. global $bp;
  18. if ( $bp->current_component == BP_SEARCH_SLUG )//if thids is search page
  19. bp_core_load_template( apply_filters( 'bp_core_template_search_template', 'search-single' ) );//load the single searh template
  20. }
  21.  
  22. function ray_secondary_avatar_fix() {
  23. remove_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 );
  24.  
  25. // add the following if you still want secondary avatars, but omitting the blog one
  26. function my_bp_dtheme_activity_secondary_avatars( $action, $activity ) {
  27. switch ( $activity->component ) {
  28. case 'groups' :
  29. case 'friends' :
  30. // Only insert avatar if one exists
  31. if ( $secondary_avatar = bp_get_activity_secondary_avatar() ) {
  32. $reverse_content = strrev( $action );
  33. $position = strpos( $reverse_content, 'a<' );
  34. $action = substr_replace( $action, $secondary_avatar, -$position - 2, 0 );
  35. }
  36. break;
  37. }
  38.  
  39. return $action;
  40. }
  41. add_filter( 'bp_get_activity_action_pre_meta', 'my_bp_dtheme_activity_secondary_avatars', 10, 2 );
  42. }
  43. add_action('init', 'ray_secondary_avatar_fix');
  44.  
  45. //show the search results for member*/
  46. function bpmag_show_member_search(){
  47. ?>
  48. <div class="memberss-search-result search-result">
  49. <h2 class="content-title"><?php _e("Members Results","bpmag");?></h2>
  50. <?php locate_template( array( 'members/members-loop.php' ), true ) ; ?>
  51. <?php global $members_template;
  52. if($members_template->total_member_count>1):?>
  53. <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>
  54. <?php endif; ?>
  55. </div>
  56. <?php
  57. }
  58.  
  59. //Hook Member results to search page
  60. 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)
  61. function bpmag_show_groups_search(){
  62. ?>
  63. <div class="groups-search-result search-result">
  64. <h2 class="content-title"><?php _e("Group Search","bpmag");?></h2>
  65. <?php locate_template( array('groups/groups-loop.php' ), true ) ; ?>
  66.  
  67. <a href="<?php echo bp_get_root_domain().'/'.BP_GROUPS_SLUG.'/?s='.$_REQUEST['s']?>" ><?php _e("View All matched Groups","bpmag");?></a>
  68. </div>
  69. <?php
  70. //endif;
  71. }
  72.  
  73. //Hook Groups results to search page
  74. if(bp_is_active( 'groups' ))
  75. add_action("advance-search","bpmag_show_groups_search",10);
  76.  
  77. /**
  78. *
  79. * Show blog posts in search
  80. */
  81. function bpmag_show_site_blog_search(){
  82. ?>
  83. <div class="blog-search-result search-result">
  84.  
  85. <h2 class="content-title"><?php _e("Blog Posts","bpmag");?></h2>
  86.  
  87. <?php locate_template( array( 'search-loop.php' ), true ) ; ?>
  88. <a href="<?php echo bp_get_root_domain().'/?s='.$_REQUEST['s']?>" ><?php _e("View All matched Posts","bpmag");?></a>
  89. </div>
  90. <?php
  91. }
  92.  
  93. //Hook Blog Post results to search page
  94. add_action("advance-search","bpmag_show_site_blog_search",10);
  95.  
  96. function bpmag_show_global_forum_search(){
  97. ?>
  98. <div>
  99. <h2>Forum Discussion Search</h2>
  100. <?php locate_template( array( 'gf/search.php' ), true ) ; ?>
  101. <a href="<?php echo bp_get_root_domain().'/'.GF_SLUG.'/?gfs='.$_REQUEST['search-terms']?>" ><?php _e("View All matched topics","bpmag");?></a>
  102. </div>
  103. <?php
  104. }
  105.  
  106. //Hook Blog Post results to search page
  107. add_action("advance-search","bpmag_show_global_forum_search",33);
  108.  
  109. //show blogs search result
  110.  
  111. function bpmag_show_blogs_search(){
  112.  
  113. ?>
  114. <div class="blogs-search-result search-result">
  115. <h2 class="content-title"><?php _e("Sites Search","bpmag");?></h2>
  116. <?php locate_template( array( 'blogs/blogs-loop.php' ), true ) ; ?>
  117. <a href="<?php echo bp_get_root_domain().'/'.BP_BLOGS_SLUG.'/?s='.$_REQUEST['s']?>" ><?php _e("View All matched Sites","bpmag");?></a>
  118. </div>
  119. <?php
  120. }
  121.  
  122. //Hook Blogs results to search page if blogs comonent is active
  123. if(bp_is_active( 'blogs' ))
  124. add_action("advance-search","bpmag_show_blogs_search",10);
  125.  
  126. //modify the query string with the search term
  127. function bpmag_global_search_qs($qs){
  128. if(bpmag_is_advance_search())
  129. return "search_terms=".$_REQUEST['s'];
  130.  
  131. return $qs;
  132.  
  133.  
  134. }
  135.  
  136. function bpmag_is_advance_search(){
  137. global $bp;
  138. if($bp->current_component == BP_SEARCH_SLUG)
  139. return true;
  140. return false;
  141. }
  142.  
  143. add_filter("bp_ajax_querystring","bpmag_global_search_qs",200);
  144.  
  145.  
  146. ?>
  147.  
  148. <?php
  149. /** 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 */
  150.  
  151. //let us remove the default handler for activity posting
  152.  
  153. remove_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' );
  154. //add our own handler for activity posting
  155.  
  156. add_action( 'wp_ajax_post_update', 'bp_mytheme_post_update' );
  157.  
  158. /* AJAX update posting */
  159. function bp_mytheme_post_update() {
  160. global $bp;
  161.  
  162. /* Check the nonce */
  163. check_admin_referer( 'post_update', '_wpnonce_post_update' );
  164.  
  165. if ( !is_user_logged_in() ) {
  166. echo '-1';
  167. return false;
  168. }
  169.  
  170. if ( empty( $_POST['content'] ) ) {
  171. echo '-1<div id="message"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>';
  172. return false;
  173. }
  174.  
  175. if ( empty( $_POST['object'] ) && function_exists( 'bp_activity_post_update' ) ) {
  176.  
  177. //this is what I have changed
  178.  
  179. if(!bp_is_home()&&bp_is_member())
  180. $content="@". bp_get_displayed_user_username()." ".$_POST['content'];
  181. else
  182. $content=$_POST['content'];
  183.  
  184. $activity_id = bp_activity_post_update( array( 'content' => $content ) );
  185.  
  186. //end of my changes
  187. } elseif ( $_POST['object'] == 'groups' ) {
  188. if ( !empty( $_POST['item_id'] ) &&function_exists( 'groups_post_update' ) )
  189. $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
  190. } else
  191. $activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] );
  192.  
  193. if ( !$activity_id ) {
  194. echo '-1<div id="message"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>';
  195. return false;
  196. }
  197.  
  198. if ( bp_has_activities ( 'include=' . $activity_id ) ) : ?>
  199. <?php while ( bp_activities() ) : bp_the_activity(); ?>
  200. <?php locate_template( array( 'activity/entry.php' ), true ) ?>
  201. <?php endwhile; ?>
  202. <?php endif;
  203. }
  204.  
  205.  
  206. register_sidebars( 1,
  207. array(
  208. 'name' => 'sidebarforum',
  209. 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
  210. 'after_widget' => '</div></div>',
  211. 'before_title' => '<h3 class="widgettitle">',
  212. 'after_title' => '</h3>'
  213. )
  214.  
  215. );
  216.  
  217. register_sidebar(
  218. array(
  219. 'name' => __('sidebar-member-center'),
  220. 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
  221. 'after_widget' => '</div></div>',
  222. 'before_title' => '<h3 class="widgettitle">',
  223. 'after_title' => '</h3>'
  224. )
  225. );
  226.  
  227. register_sidebar(
  228. array(
  229. 'name' => __('sidebar-sign-up'),
  230. 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
  231. 'after_widget' => '</div></div>',
  232. 'before_title' => '<h3 class="widgettitle">',
  233. 'after_title' => '</h3>'
  234. )
  235. );
  236.  
  237. register_sidebar(
  238. array(
  239. 'name' => __('sidebarfeatures'),
  240. 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
  241. 'after_widget' => '</div></div>',
  242. 'before_title' => '<h3 class="widgettitle">',
  243. 'after_title' => '</h3>'
  244. )
  245. );
  246.  
  247. register_sidebar(
  248. array(
  249. 'name' => __('site-features'),
  250. 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
  251. 'after_widget' => '</div></div>',
  252. 'before_title' => '<h3 class="widgettitle">',
  253. 'after_title' => '</h3>'
  254. )
  255. );
  256.  
  257. register_sidebar(
  258. array(
  259. 'name' => __('blog-school'),
  260. 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
  261. 'after_widget' => '</div></div>',
  262. 'before_title' => '<h3 class="widgettitle">',
  263. 'after_title' => '</h3>'
  264. )
  265. );
  266.  
  267. register_sidebar(
  268. array(
  269. 'name' => __('tutorials'),
  270. 'before_widget' => '<div class="light-container"><div id="%1$s" class="widget %2$s">',
  271. 'after_widget' => '</div></div>',
  272. 'before_title' => '<h3 class="widgettitle">',
  273. 'after_title' => '</h3>'
  274. )
  275. );
  276.  
  277. //remove @mentions
  278. // removes @mention links in updates, forum posts, etc.
  279. remove_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' );
  280. remove_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
  281. remove_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
  282. remove_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
  283. remove_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
  284. remove_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' );
  285. // remove @mention email notifications
  286. remove_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 );
  287. remove_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 );
  288.  
  289. function ray_remove_mention_nav() {
  290. global $bp;
  291. bp_core_remove_subnav_item( $bp->activity->slug, 'mentions' );
  292. }
  293. add_action( 'init', 'ray_remove_mention_nav' );
  294.  
  295. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement