bp_legacy_theme_ajax_messages_autocomplete_results()
AJAX handler for autocomplete.
Description Description
Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
Source Source
File: bp-templates/bp-legacy/buddypress-functions.php
function bp_legacy_theme_ajax_messages_autocomplete_results() { /** * Filters the max results default value for ajax messages autocomplete results. * * @since 1.5.0 * * @param int $value Max results for autocomplete. Default 10. */ $limit = isset( $_GET['limit'] ) ? absint( $_GET['limit'] ) : (int) apply_filters( 'bp_autocomplete_max_results', 10 ); $term = isset( $_GET['q'] ) ? sanitize_text_field( $_GET['q'] ) : ''; // Include everyone in the autocomplete, or just friends? if ( bp_is_current_component( bp_get_messages_slug() ) ) { $only_friends = ( buddypress()->messages->autocomplete_all === false ); } else { $only_friends = true; } $suggestions = bp_core_get_suggestions( array( 'limit' => $limit, 'only_friends' => $only_friends, 'term' => $term, 'type' => 'members', ) ); if ( $suggestions && ! is_wp_error( $suggestions ) ) { foreach ( $suggestions as $user ) { // Note that the final line break acts as a delimiter for the // autocomplete JavaScript and thus should not be removed. printf( '<span id="%s" href="#"></span><img src="%s" style="width: 15px"> %s (%s)' . "\n", esc_attr( 'link-' . $user->ID ), esc_url( $user->image ), esc_html( $user->name ), esc_html( $user->ID ) ); } } exit; }
Changelog Changelog
Version | Description |
---|---|
1.2.0 | Introduced. |