Skip to:
Content

BuddyPress.org

Ticket #5934: 5934.02.patch

File 5934.02.patch, 3.0 KB (added by imath, 10 years ago)
  • src/bp-activity/bp-activity-actions.php

    diff --git src/bp-activity/bp-activity-actions.php src/bp-activity/bp-activity-actions.php
    index 17f23e6..54d9184 100644
    function bp_ajax_get_suggestions() { 
    753753                exit;
    754754        }
    755755
    756         $results = bp_core_get_suggestions( array(
     756        $args = bp_parse_args( array(
    757757                'term' => sanitize_text_field( $_GET['term'] ),
    758758                'type' => sanitize_text_field( $_GET['type'] ),
    759         ) );
     759        ), array(
     760                'term' => '',
     761                'type' => 'alphabetical',
     762        ), 'ajax_get_suggestions' );
     763
     764        $results = bp_core_get_suggestions( $args );
    760765
    761766        if ( is_wp_error( $results ) ) {
    762767                wp_send_json_error( $results->get_error_message() );
  • src/bp-groups/bp-groups-filters.php

    diff --git src/bp-groups/bp-groups-filters.php src/bp-groups/bp-groups-filters.php
    index 9e66f3d..24ba0cc 100644
    function groups_filter_forums_root_page_sql( $sql ) { 
    233233        return apply_filters( 'groups_filter_bbpress_root_page_sql', 't.topic_id' );
    234234}
    235235add_filter( 'get_latest_topics_fields', 'groups_filter_forums_root_page_sql' );
     236
     237
     238
     239/** BuddyPress Mentions for single groups *************************************/
     240
     241/**
     242 * Make sure Mentions JS are loaded when on a Groups single item
     243 *
     244 * @since BuddyPress (2.2.0)
     245 *
     246 * @param  bool whether to load or not JS
     247 * @uses   bp_is_group_activity() to check if the current page is a group's activity page
     248 * @uses   bp_is_group_home() to check if the current page is a single group's home page?
     249 * @uses   bp_is_group_forum_topic_edit() to check if the current page is a group forum topic edit page
     250 * @return bool        true if on a Groups single item
     251 */
     252function bp_groups_load_mentions_scripts( $load = false ) {
     253        if ( empty( $load ) ) {
     254                $load = bp_is_group_activity() || bp_is_group_home() || bp_is_group_forum_topic_edit();
     255                remove_action( 'bp_activity_mentions_prime_results', 'bp_friends_prime_mentions_results' );
     256        }
     257
     258        return $load;
     259}
     260add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_groups_load_mentions_scripts', 10, 1 );
     261
     262/**
     263 * Make sure only the group members will be fetched when on a Groups single item
     264 *
     265 * @since BuddyPress (2.2.0)
     266 *
     267 * @param  array $args the suggestions arguments
     268 * @uses   bp_is_group_activity() to check if the current page is a group's activity page
     269 * @uses   bp_is_group_home() to check if the current page is a single group's home page?
     270 * @uses   bp_is_group_forum_topic_edit() to check if the current page is a group forum topic edit page
     271 * @uses   bp_get_current_group_id() to get the current group id
     272 * @return array       the suggestions arguments including group_id if needed
     273 */
     274function bp_groups_get_group_member_suggestions_args( $args = array() ) {
     275        if ( ! bp_is_group_activity() && ! bp_is_group_home() && ! bp_is_group_forum_topic_edit() ) {
     276                return $args;
     277        }
     278
     279        $args['group_id'] = bp_get_current_group_id();
     280
     281        return $args;
     282}
     283add_filter( 'bp_before_ajax_get_suggestions_parse_args', 'bp_groups_get_group_member_suggestions_args', 10, 1 );