Skip to:
Content

BuddyPress.org

Ticket #3388: 3388.004.patch

File 3388.004.patch, 10.3 KB (added by thebrandonallen, 12 years ago)
  • bp-activity/bp-activity-actions.php

     
    534534function bp_activity_action_mentions_feed() {
    535535        global $wp_query;
    536536
    537         if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
     537        if ( !bp_activity_do_mentions() || !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
    538538                return false;
    539539
    540540        $wp_query->is_404 = false;
  • bp-activity/bp-activity-filters.php

     
    8686add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' );
    8787add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );
    8888
    89 add_filter( 'pre_comment_content',                   'bp_activity_at_name_filter' );
    90 add_filter( 'group_forum_topic_text_before_save',    'bp_activity_at_name_filter' );
    91 add_filter( 'group_forum_post_text_before_save',     'bp_activity_at_name_filter' );
    92 add_filter( 'the_content',                           'bp_activity_at_name_filter' );
     89if ( bp_activity_do_mentions() ) {
     90        add_filter( 'pre_comment_content',                   'bp_activity_at_name_filter' );
     91        add_filter( 'group_forum_topic_text_before_save',    'bp_activity_at_name_filter' );
     92        add_filter( 'group_forum_post_text_before_save',     'bp_activity_at_name_filter' );
     93        add_filter( 'the_content',                           'bp_activity_at_name_filter' );
     94}
    9395
    9496add_filter( 'bp_get_activity_parent_content',        'bp_create_excerpt' );
    9597
     
    99101/** Actions *******************************************************************/
    100102
    101103// At-name filter
    102 add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' );
     104if ( bp_activity_do_mentions() )
     105        add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' );
    103106
    104107// Activity stream moderation
    105108add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 );
     
    207210 * @return string $content Content filtered for mentions
    208211 */
    209212function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
     213       
     214        // Are mentions disabled?
     215        if ( !bp_activity_do_mentions() )
     216                return $content;
    210217
    211218        // Try to find mentions
    212219        $usernames = bp_activity_find_mentions( $content );
     
    237244 * @uses bp_activity_find_mentions()
    238245 */
    239246function bp_activity_at_name_filter_updates( $activity ) {
     247        // Are mentions disabled?
     248        if ( !bp_activity_do_mentions() )
     249                return;
     250
    240251        // If activity was marked as spam, stop the rest of this function.
    241252        if ( ! empty( $activity->is_spam ) )
    242253                return;
    243 
     254       
    244255        // Try to find mentions
    245256        $usernames = bp_activity_find_mentions( $activity->content );
    246257
     
    271282 * @uses bp_activity_update_mention_count_for_user()
    272283 */
    273284function bp_activity_at_name_send_emails( $activity ) {
     285        // Are mentions disabled?
     286        if ( !bp_activity_do_mentions() )
     287                return;
     288
    274289        // If our temporary variable doesn't exist, stop now.
    275290        if ( empty( buddypress()->activity->mentioned_users ) )
    276291                return;
     
    363378
    364379        return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
    365380}
     381
     382/**
     383 * Are mentions enabled or disabled?
     384 *
     385 * @package BuddyPress Activity
     386 * @since 1.8
     387 *
     388 * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
     389 * @return bool $retval True to enable mentions, false to disable. Defaults to true.
     390 */
     391function bp_activity_do_mentions() {
     392        // Default to true
     393        $retval = true;
     394
     395        return (bool) apply_filters( 'bp_activity_do_mentions', $retval );
     396}
     397 No newline at end of file
  • bp-activity/bp-activity-loader.php

     
    150150                );
    151151
    152152                // @ mentions
    153                 $sub_nav[] = array(
    154                         'name'            => __( 'Mentions', 'buddypress' ),
    155                         'slug'            => 'mentions',
    156                         'parent_url'      => $activity_link,
    157                         'parent_slug'     => $this->slug,
    158                         'screen_function' => 'bp_activity_screen_mentions',
    159                         'position'        => 20,
    160                         'item_css_id'     => 'activity-mentions'
    161                 );
     153                if ( bp_activity_do_mentions() ) {
     154                        $sub_nav[] = array(
     155                                'name'            => __( 'Mentions', 'buddypress' ),
     156                                'slug'            => 'mentions',
     157                                'parent_url'      => $activity_link,
     158                                'parent_slug'     => $this->slug,
     159                                'screen_function' => 'bp_activity_screen_mentions',
     160                                'position'        => 20,
     161                                'item_css_id'     => 'activity-mentions'
     162                        );
     163                }
    162164
    163165                // Favorite activity items
    164166                $sub_nav[] = array(
     
    228230                        $activity_link = trailingslashit( $user_domain . $this->slug );
    229231
    230232                        // Unread message count
    231                         $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
    232                         if ( !empty( $count ) ) {
    233                                 $title = sprintf( __( 'Mentions <span class="count">%s</span>', 'buddypress' ), number_format_i18n( $count ) );
    234                         } else {
    235                                 $title = __( 'Mentions', 'buddypress' );
     233                        if ( bp_activity_do_mentions() ) {
     234                                $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
     235                                if ( !empty( $count ) ) {
     236                                        $title = sprintf( __( 'Mentions <span class="count">%s</span>', 'buddypress' ), number_format_i18n( $count ) );
     237                                } else {
     238                                        $title = __( 'Mentions', 'buddypress' );
     239                                }
    236240                        }
    237241
    238242                        // Add the "Activity" sub menu
     
    244248                        );
    245249
    246250                        // Mentions
    247                         $wp_admin_nav[] = array(
    248                                 'parent' => 'my-account-' . $this->id,
    249                                 'id'     => 'my-account-' . $this->id . '-mentions',
    250                                 'title'  => $title,
    251                                 'href'   => trailingslashit( $activity_link . 'mentions' )
    252                         );
     251                        if ( bp_activity_do_mentions() ) {
     252                                $wp_admin_nav[] = array(
     253                                        'parent' => 'my-account-' . $this->id,
     254                                        'id'     => 'my-account-' . $this->id . '-mentions',
     255                                        'title'  => $title,
     256                                        'href'   => trailingslashit( $activity_link . 'mentions' )
     257                                );
     258                        }
    253259
    254260                        // Personal
    255261                        $wp_admin_nav[] = array(
  • bp-activity/bp-activity-screens.php

     
    265265 */
    266266function bp_activity_screen_notification_settings() {
    267267
    268         if ( !$mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) )
    269                 $mention = 'yes';
     268        if ( bp_activity_do_mentions() ) {
     269                if ( !$mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) )
     270                        $mention = 'yes';
     271        }
    270272
    271273        if ( !$reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) )
    272274                $reply = 'yes'; ?>
     
    282284                </thead>
    283285
    284286                <tbody>
     287                        <?php if ( bp_activity_do_mentions() ) : ?>
    285288                        <tr id="activity-notification-settings-mentions">
    286289                                <td>&nbsp;</td>
    287290                                <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td>
    288291                                <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
    289292                                <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
    290293                        </tr>
     294                        <?php endif; ?>
    291295                        <tr id="activity-notification-settings-replies">
    292296                                <td>&nbsp;</td>
    293297                                <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
  • bp-activity/bp-activity-template.php

     
    419419                                        break;
    420420                                case 'mentions':
    421421
     422                                        // Are mentions disabled?
     423                                        if ( bp_activity_do_mentions() )
     424                                                return false;
     425
    422426                                        // Start search at @ symbol and stop search at closing tag delimiter.
    423427                                        $search_terms     = '@' . bp_core_get_username( $user_id ) . '<';
    424428                                        $display_comments = 'stream';
     
    27702774                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
    27712775                elseif ( 'favorites' == bp_current_action() )
    27722776                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
    2773                 elseif ( 'mentions' == bp_current_action() )
     2777                elseif ( 'mentions' == bp_current_action() && bp_activity_do_mentions() )
    27742778                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
    27752779                else
    27762780                        $link = '';
  • bp-themes/bp-default/activity/index.php

     
    7272
    7373                                                <?php endif; ?>
    7474
     75                                                <?php if ( bp_activity_do_mentions() ) : ?>
     76
    7577                                                <?php do_action( 'bp_before_activity_type_tab_mentions' ); ?>
    7678
    7779                                                <li id="activity-mentions"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/'; ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ); ?>"><?php _e( 'Mentions', 'buddypress' ); ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><span><?php printf( _nx( '%s new', '%s new', bp_get_total_mention_count_for_user( bp_loggedin_user_id() ), 'Number of new activity mentions', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ); ?></span></strong><?php endif; ?></a></li>
     80                                                       
     81                                                <?php endif; ?>
    7882
    7983                                        <?php endif; ?>
    8084
  • bp-themes/bp-default/functions.php

     
    119119                        add_action( 'bp_member_header_actions',    'bp_add_friend_button',           5 );
    120120
    121121                // Activity button
    122                 if ( bp_is_active( 'activity' ) )
     122                if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() )
    123123                        add_action( 'bp_member_header_actions',    'bp_send_public_message_button',  20 );
    124124
    125125                // Messages button