bp_core_action_search_site( string $slug = '' )
A JavaScript-free implementation of the search functions in BuddyPress.
Description
Parameters
- $slug
-
(Optional) The slug to redirect to for searching.
Default value: ''
Source
File: bp-core/bp-core-functions.php
2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 | function bp_core_action_search_site( $slug = '' ) { if ( ! bp_is_current_component( bp_get_search_slug() ) ) { return ; } if ( empty ( $_POST [ 'search-terms' ] ) ) { bp_core_redirect( bp_get_root_domain() ); return ; } $search_terms = stripslashes ( $_POST [ 'search-terms' ] ); $search_which = ! empty ( $_POST [ 'search-which' ] ) ? $_POST [ 'search-which' ] : '' ; $query_string = '/?s=' ; if ( empty ( $slug ) ) { switch ( $search_which ) { case 'posts' : $slug = '' ; $var = '/?s=' ; // If posts aren't displayed on the front page, find the post page's slug. if ( 'page' == get_option( 'show_on_front' ) ) { $page = get_post( get_option( 'page_for_posts' ) ); if ( !is_wp_error( $page ) && ! empty ( $page ->post_name ) ) { $slug = $page ->post_name; $var = '?s=' ; } } break ; case 'blogs' : $slug = bp_is_active( 'blogs' ) ? bp_get_blogs_root_slug() : '' ; break ; case 'groups' : $slug = bp_is_active( 'groups' ) ? bp_get_groups_root_slug() : '' ; break ; case 'members' : default : $slug = bp_get_members_root_slug(); break ; } if ( empty ( $slug ) && 'posts' != $search_which ) { bp_core_redirect( bp_get_root_domain() ); return ; } } /** * Filters the constructed url for use with site searching. * * @since BuddyPress 1.0.0 * * @param string $value URL for use with site searching. * @param array $search_terms Array of search terms. */ bp_core_redirect( apply_filters( 'bp_core_search_site' , home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.0.1 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.