bp_get_search_default_text( string $component = '' )
Return the default text for the search box for a given component.
Description
Parameters
- $component
-
(Optional) Component name. Default: current component.
Default value: ''
Return
(string) Placeholder text for search field.
Source
File: bp-core/bp-core-template.php
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | function bp_get_search_default_text( $component = '' ) { $bp = buddypress(); if ( empty ( $component ) ) { $component = bp_current_component(); } $default_text = __( 'Search anything…' , 'buddyboss' ); // Most of the time, $component will be the actual component ID. if ( ! empty ( $component ) ) { if ( ! empty ( $bp ->{ $component }->search_string ) ) { $default_text = $bp ->{ $component }->search_string; } else { // When the request comes through AJAX, we need to get the component // name out of $bp->pages. if ( ! empty ( $bp ->pages->{ $component }->slug ) ) { $key = $bp ->pages->{ $component }->slug; if ( ! empty ( $bp ->{ $key }->search_string ) ) { $default_text = $bp ->{ $key }->search_string; } } } } /** * Filters the default text for the search box for a given component. * * @since BuddyPress 1.5.0 * * @param string $default_text Default text for search box. * @param string $component Current component displayed. */ return apply_filters( 'bp_get_search_default_text' , $default_text , $component ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.5.0 | 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.