Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2018 07:17:12 PM (8 years ago)
Author:
boonebgorges
Message:

Move bp_ajax_get_suggestions() handler to Core component.

It was previously located in the Activity component, which made it
impossible to do an AJAX suggestions query (such as in the case of
Messages) when Activity was disabled.

Props imath.

See #7951.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-functions.php

    r12281 r12286  
    39183918
    39193919/**
    3920  * AJAX endpoint for Suggestions API lookups.
    3921  *
    3922  * @since 2.1.0
    3923  */
    3924 function bp_ajax_get_suggestions() {
    3925         if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
    3926                 wp_send_json_error( 'missing_parameter' );
    3927                 exit;
    3928         }
    3929 
    3930         $args = array(
    3931                 'term' => sanitize_text_field( $_GET['term'] ),
    3932                 'type' => sanitize_text_field( $_GET['type'] ),
    3933         );
    3934 
    3935         // Support per-Group suggestions.
    3936         if ( ! empty( $_GET['group-id'] ) ) {
    3937                 $args['group_id'] = absint( $_GET['group-id'] );
    3938         }
    3939 
    3940         $results = bp_core_get_suggestions( $args );
    3941 
    3942         if ( is_wp_error( $results ) ) {
    3943                 wp_send_json_error( $results->get_error_message() );
    3944                 exit;
    3945         }
    3946 
    3947         wp_send_json_success( $results );
    3948 }
    3949 add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
    3950 
    3951 /**
    39523920 * Detect a change in post type status, and initiate an activity update if necessary.
    39533921 *
Note: See TracChangeset for help on using the changeset viewer.