bp_get_search_default_text( string $component = '' )
Return the default text for the search box for a given component.
Description Description
Parameters Parameters
- $component
-
(Optional) Component name. Default: current component.
Default value: ''
Return Return
(string) Placeholder text for search field.
Source Source
File: bp-core/bp-core-template.php
function bp_get_search_default_text( $component = '' ) {
$bp = buddypress();
if ( empty( $component ) ) {
$component = bp_current_component();
}
$default_text = __( 'Search anything...', 'buddypress' );
// 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 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 Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |