Index: bp-activity/bp-activity-actions.php =================================================================== --- bp-activity/bp-activity-actions.php (revision 7148) +++ bp-activity/bp-activity-actions.php (working copy) @@ -534,7 +534,7 @@ function bp_activity_action_mentions_feed() { global $wp_query; - if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) ) + if ( !bp_activity_do_mentions() || !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) ) return false; $wp_query->is_404 = false; Index: bp-activity/bp-activity-filters.php =================================================================== --- bp-activity/bp-activity-filters.php (revision 7148) +++ bp-activity/bp-activity-filters.php (working copy) @@ -86,10 +86,12 @@ add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' ); add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' ); -add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' ); -add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' ); -add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' ); -add_filter( 'the_content', 'bp_activity_at_name_filter' ); +if ( bp_activity_do_mentions() ) { + add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' ); + add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' ); + add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' ); + add_filter( 'the_content', 'bp_activity_at_name_filter' ); +} add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' ); @@ -99,7 +101,8 @@ /** Actions *******************************************************************/ // At-name filter -add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' ); +if ( bp_activity_do_mentions() ) + add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' ); // Activity stream moderation add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 ); @@ -207,6 +210,10 @@ * @return string $content Content filtered for mentions */ function bp_activity_at_name_filter( $content, $activity_id = 0 ) { + + // Are mentions disabled? + if ( !bp_activity_do_mentions() ) + return $content; // Try to find mentions $usernames = bp_activity_find_mentions( $content ); @@ -237,10 +244,14 @@ * @uses bp_activity_find_mentions() */ function bp_activity_at_name_filter_updates( $activity ) { + // Are mentions disabled? + if ( !bp_activity_do_mentions() ) + return; + // If activity was marked as spam, stop the rest of this function. if ( ! empty( $activity->is_spam ) ) return; - + // Try to find mentions $usernames = bp_activity_find_mentions( $activity->content ); @@ -271,6 +282,10 @@ * @uses bp_activity_update_mention_count_for_user() */ function bp_activity_at_name_send_emails( $activity ) { + // Are mentions disabled? + if ( !bp_activity_do_mentions() ) + return; + // If our temporary variable doesn't exist, stop now. if ( empty( buddypress()->activity->mentioned_users ) ) return; @@ -363,3 +378,19 @@ return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text ); } + +/** + * Are mentions enabled or disabled? + * + * @package BuddyPress Activity + * @since 1.8 + * + * @uses apply_filters() To call 'bp_activity_do_mentions' hook. + * @return bool $retval True to enable mentions, false to disable. Defaults to true. + */ +function bp_activity_do_mentions() { + // Default to true + $retval = true; + + return (bool) apply_filters( 'bp_activity_do_mentions', $retval ); +} \ No newline at end of file Index: bp-activity/bp-activity-loader.php =================================================================== --- bp-activity/bp-activity-loader.php (revision 7148) +++ bp-activity/bp-activity-loader.php (working copy) @@ -150,15 +150,17 @@ ); // @ mentions - $sub_nav[] = array( - 'name' => __( 'Mentions', 'buddypress' ), - 'slug' => 'mentions', - 'parent_url' => $activity_link, - 'parent_slug' => $this->slug, - 'screen_function' => 'bp_activity_screen_mentions', - 'position' => 20, - 'item_css_id' => 'activity-mentions' - ); + if ( bp_activity_do_mentions() ) { + $sub_nav[] = array( + 'name' => __( 'Mentions', 'buddypress' ), + 'slug' => 'mentions', + 'parent_url' => $activity_link, + 'parent_slug' => $this->slug, + 'screen_function' => 'bp_activity_screen_mentions', + 'position' => 20, + 'item_css_id' => 'activity-mentions' + ); + } // Favorite activity items $sub_nav[] = array( @@ -228,11 +230,13 @@ $activity_link = trailingslashit( $user_domain . $this->slug ); // Unread message count - $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() ); - if ( !empty( $count ) ) { - $title = sprintf( __( 'Mentions %s', 'buddypress' ), number_format_i18n( $count ) ); - } else { - $title = __( 'Mentions', 'buddypress' ); + if ( bp_activity_do_mentions() ) { + $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() ); + if ( !empty( $count ) ) { + $title = sprintf( __( 'Mentions %s', 'buddypress' ), number_format_i18n( $count ) ); + } else { + $title = __( 'Mentions', 'buddypress' ); + } } // Add the "Activity" sub menu @@ -244,12 +248,14 @@ ); // Mentions - $wp_admin_nav[] = array( - 'parent' => 'my-account-' . $this->id, - 'id' => 'my-account-' . $this->id . '-mentions', - 'title' => $title, - 'href' => trailingslashit( $activity_link . 'mentions' ) - ); + if ( bp_activity_do_mentions() ) { + $wp_admin_nav[] = array( + 'parent' => 'my-account-' . $this->id, + 'id' => 'my-account-' . $this->id . '-mentions', + 'title' => $title, + 'href' => trailingslashit( $activity_link . 'mentions' ) + ); + } // Personal $wp_admin_nav[] = array( Index: bp-activity/bp-activity-screens.php =================================================================== --- bp-activity/bp-activity-screens.php (revision 7148) +++ bp-activity/bp-activity-screens.php (working copy) @@ -265,8 +265,10 @@ */ function bp_activity_screen_notification_settings() { - if ( !$mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) ) - $mention = 'yes'; + if ( bp_activity_do_mentions() ) { + if ( !$mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) ) + $mention = 'yes'; + } if ( !$reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) ) $reply = 'yes'; ?> @@ -282,12 +284,14 @@
+