Changeset 3511 for trunk/bp-core.php
- Timestamp:
- 12/04/2010 11:41:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r3490 r3511 1679 1679 * @package BuddyPress Core 1680 1680 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 1681 * @param $slug The slug to redirect to for searching. 1682 */ 1683 function bp_core_action_search_site( $slug = false ) { 1684 global $bp; 1685 1686 if ( $bp->current_component == BP_SEARCH_SLUG ) { 1687 $search_terms = $_POST['search-terms']; 1688 $search_which = $_POST['search-which']; 1689 1690 if ( !$slug || empty( $slug ) ) { 1691 switch ( $search_which ) { 1692 case 'members': default: 1693 $slug = $bp->members->slug; 1694 $var = '/?s='; 1695 break; 1696 case 'groups': 1697 $slug = BP_GROUPS_SLUG; 1698 $var = '/?s='; 1699 break; 1700 case 'forums': 1701 $slug = BP_FORUMS_SLUG; 1702 $var = '/?fs='; 1703 break; 1704 case 'blogs': 1705 $slug = BP_BLOGS_SLUG; 1706 $var = '/?s='; 1707 break; 1708 } 1681 * @param string $slug The slug to redirect to for searching. 1682 */ 1683 function bp_core_action_search_site( $slug = '' ) { 1684 global $bp; 1685 1686 if ( BP_SEARCH_SLUG != $bp->current_component ) 1687 return; 1688 1689 if ( empty( $_POST['search-terms'] ) ) { 1690 bp_core_redirect( $bp->root_domain ); 1691 return; 1692 } 1693 1694 $search_terms = stripslashes( $_POST['search-terms'] ); 1695 $search_which = !empty( $_POST['search-which'] ) ? $_POST['search-which'] : ''; 1696 $query_string = '/?s='; 1697 1698 if ( empty( $slug ) ) { 1699 switch ( $search_which ) { 1700 case 'blogs': 1701 $slug = bp_is_active( 'blogs' ) ? $bp->blogs->slug : ''; 1702 break; 1703 case 'forums': 1704 $slug = bp_is_active( 'forums' ) ? $bp->forums->slug : ''; 1705 $query_string = '/?fs='; 1706 break; 1707 case 'groups': 1708 $slug = bp_is_active( 'groups' ) ? $bp->groups->slug : ''; 1709 break; 1710 case 'members': 1711 default: 1712 $slug = $bp->members->slug; 1713 break; 1709 1714 } 1710 1715 1711 $search_url = apply_filters( 'bp_core_search_site', site_url( $slug . $var . urlencode($search_terms) ), $search_terms ); 1712 1713 bp_core_redirect( $search_url ); 1714 } 1716 if ( empty( $slug ) ) { 1717 bp_core_redirect( $bp->root_domain ); 1718 return; 1719 } 1720 } 1721 1722 bp_core_redirect( apply_filters( 'bp_core_search_site', site_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) ); 1715 1723 } 1716 1724 add_action( 'init', 'bp_core_action_search_site', 5 );
Note: See TracChangeset
for help on using the changeset viewer.