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() { |
3916 | 3916 | return (bool) apply_filters( 'bp_activity_do_heartbeat', $retval ); |
3917 | 3917 | } |
3918 | 3918 | |
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 | | |
3951 | 3919 | /** |
3952 | 3920 | * Detect a change in post type status, and initiate an activity update if necessary. |
3953 | 3921 | * |
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 ) { |
2767 | 2767 | return apply_filters( 'bp_core_get_suggestions', $retval, $args ); |
2768 | 2768 | } |
2769 | 2769 | |
| 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 | */ |
| 2777 | function 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 | } |
| 2802 | add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' ); |
| 2803 | |
2770 | 2804 | /** |
2771 | 2805 | * Set data from the BP root blog's upload directory. |
2772 | 2806 | * |