Skip to:
Content

BuddyPress.org

Ticket #7951: 7951.02.patch

File 7951.02.patch, 2.5 KB (added by imath, 6 years ago)

Moves bp_ajax_get_suggestions() into src/bp-core/bp-core-functions.php

  • src/bp-activity/bp-activity-functions.php

    diff --git src/bp-activity/bp-activity-functions.php src/bp-activity/bp-activity-functions.php
    index 30c8fc567..90683de56 100644
    function bp_activity_do_heartbeat() { 
    39163916        return (bool) apply_filters( 'bp_activity_do_heartbeat', $retval );
    39173917}
    39183918
    3919 /**
    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 
    39513919/**
    39523920 * Detect a change in post type status, and initiate an activity update if necessary.
    39533921 *
  • src/bp-core/bp-core-functions.php

    diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
    index cc41d689e..a88898171 100644
    function bp_core_get_suggestions( $args ) { 
    27672767        return apply_filters( 'bp_core_get_suggestions', $retval, $args );
    27682768}
    27692769
     2770/**
     2771 * AJAX endpoint for Suggestions API lookups.
     2772 *
     2773 * @since  2.1.0
     2774 * @since  3.3.0 Moved here to make sure this function is available
     2775 *               even if the Activity component is not active.
     2776 */
     2777function bp_ajax_get_suggestions() {
     2778        if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
     2779                wp_send_json_error( 'missing_parameter' );
     2780                exit;
     2781        }
     2782
     2783        $args = array(
     2784                'term' => sanitize_text_field( $_GET['term'] ),
     2785                'type' => sanitize_text_field( $_GET['type'] ),
     2786        );
     2787
     2788        // Support per-Group suggestions.
     2789        if ( ! empty( $_GET['group-id'] ) ) {
     2790                $args['group_id'] = absint( $_GET['group-id'] );
     2791        }
     2792
     2793        $results = bp_core_get_suggestions( $args );
     2794
     2795        if ( is_wp_error( $results ) ) {
     2796                wp_send_json_error( $results->get_error_message() );
     2797                exit;
     2798        }
     2799
     2800        wp_send_json_success( $results );
     2801}
     2802add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
     2803
    27702804/**
    27712805 * Set data from the BP root blog's upload directory.
    27722806 *