| 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 | */ |
| 252 | function 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 | } |
| 260 | add_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 | */ |
| 274 | function 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 | } |
| 283 | add_filter( 'bp_before_ajax_get_suggestions_parse_args', 'bp_groups_get_group_member_suggestions_args', 10, 1 ); |