Skip to:
Content

BuddyPress.org

Changeset 7193


Ignore:
Timestamp:
06/09/2013 02:04:36 PM (8 years ago)
Author:
boonebgorges
Message:

Introduces bp_activity_do_mentions(), a toggle for the activity mentions feature

Fixes #3388

Props thebrandonallen

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-actions.php

    r6981 r7193  
    535535    global $wp_query;
    536536
     537    if ( ! bp_activity_do_mentions() ) {
     538        return false;
     539    }
     540
    537541    if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
    538542        return false;
  • trunk/bp-activity/bp-activity-filters.php

    r6649 r7193  
    209209function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
    210210
     211    // Are mentions disabled?
     212    if ( ! bp_activity_do_mentions() ) {
     213        return $content;
     214    }
     215
    211216    // Try to find mentions
    212217    $usernames = bp_activity_find_mentions( $content );
     
    238243 */
    239244function bp_activity_at_name_filter_updates( $activity ) {
     245    // Are mentions disabled?
     246    if ( ! bp_activity_do_mentions() ) {
     247        return;
     248    }
     249
    240250    // If activity was marked as spam, stop the rest of this function.
    241251    if ( ! empty( $activity->is_spam ) )
     
    272282 */
    273283function bp_activity_at_name_send_emails( $activity ) {
     284    // Are mentions disabled?
     285    if ( ! bp_activity_do_mentions() ) {
     286        return;
     287    }
     288
    274289    // If our temporary variable doesn't exist, stop now.
    275290    if ( empty( buddypress()->activity->mentioned_users ) )
  • trunk/bp-activity/bp-activity-functions.php

    r7115 r7193  
    2626
    2727    return (bool) !empty( $bp->pages->activity->id );
     28}
     29
     30/**
     31 * Are mentions enabled or disabled?
     32 *
     33 * The Mentions feature does a number of things, all of which will be turned
     34 * off if you disable mentions:
     35 *   - Detecting and auto-linking @username in all BP/WP content
     36 *   - Sending BP notifications and emails to users when they are mentioned
     37 *     using the @username syntax
     38 *   - The Public Message button on user profiles
     39 *
     40 * Mentions are enabled by default. To disable, put the following line in
     41 * bp-custom.php or your theme's functions.php file:
     42 *
     43 *   add_filter( 'bp_activity_do_mentions', '__return_false' );
     44 *
     45 * @since BuddyPress (1.8)
     46 *
     47 * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
     48 * @return bool $retval True to enable mentions, false to disable.
     49 */
     50function bp_activity_do_mentions() {
     51    return (bool) apply_filters( 'bp_activity_do_mentions', true );
    2852}
    2953
  • trunk/bp-activity/bp-activity-loader.php

    r6734 r7193  
    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
     
    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
     
    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
  • trunk/bp-activity/bp-activity-screens.php

    r6596 r7193  
    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';
    270 
    271     if ( !$reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) )
    272         $reply = '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        }
     272    }
     273
     274    if ( ! $reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) ) {
     275        $reply = 'yes';
     276    }
     277
     278    ?>
    273279
    274280    <table class="notification-settings" id="activity-notification-settings">
     
    283289
    284290        <tbody>
    285             <tr id="activity-notification-settings-mentions">
    286                 <td>&nbsp;</td>
    287                 <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td>
    288                 <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
    289                 <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
    290             </tr>
     291            <?php if ( bp_activity_do_mentions() ) : ?>
     292                <tr id="activity-notification-settings-mentions">
     293                    <td>&nbsp;</td>
     294                    <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td>
     295                    <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
     296                    <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
     297                </tr>
     298            <?php endif; ?>
     299
    291300            <tr id="activity-notification-settings-replies">
    292301                <td>&nbsp;</td>
  • trunk/bp-activity/bp-activity-template.php

    r7168 r7193  
    419419                    break;
    420420                case 'mentions':
     421
     422                    // Are mentions disabled?
     423                    if ( ! bp_activity_do_mentions() ) {
     424                        return false;
     425                    }
    421426
    422427                    // Start search at @ symbol and stop search at closing tag delimiter.
     
    27992804        elseif ( 'favorites' == bp_current_action() )
    28002805            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
    2801         elseif ( 'mentions' == bp_current_action() )
     2806        elseif ( 'mentions' == bp_current_action() && bp_activity_do_mentions() )
    28022807            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
    28032808        else
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r7151 r7193  
    100100
    101101            // Activity button
    102             if ( bp_is_active( 'activity' ) )
     102            if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() )
    103103                add_action( 'bp_member_header_actions',    'bp_send_public_message_button',  20 );
    104104
  • trunk/bp-templates/bp-legacy/buddypress/activity/index.php

    r7177 r7193  
    5353                <?php endif; ?>
    5454
    55                 <?php do_action( 'bp_before_activity_type_tab_mentions' ); ?>
     55                <?php if ( bp_activity_do_mentions() ) : ?>
    5656
    57                 <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' ), number_format_i18n( bp_get_total_mention_count_for_user( bp_loggedin_user_id()  )) ); ?></span></strong><?php endif; ?></a></li>
     57                    <?php do_action( 'bp_before_activity_type_tab_mentions' ); ?>
     58
     59                    <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' ), number_format_i18n( bp_get_total_mention_count_for_user( bp_loggedin_user_id()  )) ); ?></span></strong><?php endif; ?></a></li>
     60
     61                <?php endif; ?>
    5862
    5963            <?php endif; ?>
  • trunk/bp-themes/bp-default/activity/index.php

    r7004 r7193  
    7373                        <?php endif; ?>
    7474
    75                         <?php do_action( 'bp_before_activity_type_tab_mentions' ); ?>
     75                        <?php if ( bp_activity_do_mentions() ) : ?>
    7676
    77                         <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>
     77                            <?php do_action( 'bp_before_activity_type_tab_mentions' ); ?>
     78
     79                            <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; ?>
  • trunk/bp-themes/bp-default/functions.php

    r7002 r7193  
    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
Note: See TracChangeset for help on using the changeset viewer.