Advertisement
imath

Code of my comment on Brajesh blog

Jun 27th, 2012
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <?php
  2. /*** i commented on http://buddydev.com/buddypress/making-buddypress-activity-searchable/ ***/
  3.  
  4. /***** the src-activity.js file *****/
  5. ?>
  6. jQuery(document).ready(function($){
  7.    
  8.     if( $('form#search-form #search-which').length ) {
  9.        
  10.         if ( '' != $.cookie('bp-activity-search-terms') ) {
  11.            
  12.             $('form#search-form #search-which option[value="activity"]').prop( 'selected', true );
  13.             $('form#search-form #search-terms').val( $.cookie('bp-activity-search-terms') );
  14.         }
  15.            
  16.        
  17.         $('#search-submit').click(function(){
  18.            
  19.             if( $('form#search-form #search-which').val() == "activity" ) {
  20.                
  21.                 search_terms = $('form#search-form #search-terms').val();
  22.                
  23.                 if(search_terms.length == 0)
  24.                     $.cookie( 'bp-activity-search-terms', '', {path: '/'} );
  25.                
  26.                 else
  27.                     $.cookie( 'bp-activity-search-terms', search_terms, {path: '/'} );
  28.                
  29.             } else {
  30.                 $.cookie( 'bp-activity-search-terms', '', {path: '/'} );
  31.             }
  32.            
  33.         })
  34.        
  35.     }
  36.    
  37. });
  38.  
  39. <?php
  40. /***** now lines 65 to 67 replacement in your class final code ******/
  41.  
  42. $_BP_COOKIE = &$_COOKIE;
  43. if ( isset( $_BP_COOKIE['bp-activity-search-terms'] )  && !empty( $_BP_COOKIE['bp-activity-search-terms'] ) ) {
  44.    
  45.     if( empty($qs) )
  46.         $qs="search_terms=".$_BP_COOKIE['bp-activity-search-terms'];
  47.        
  48.     else
  49.         $qs .= "&search_terms=".$_BP_COOKIE['bp-activity-search-terms'];
  50.    
  51. }
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement