Skip to:
Content

BuddyPress.org

Ticket #3388: 3388.001.diff

File 3388.001.diff, 10.4 KB (added by cnorris23, 14 years ago)

filter only

  • bp-themes/bp-default/activity/index.php

     
    7272
    7373                                                <?php do_action( 'bp_before_activity_type_tab_mentions' ) ?>
    7474
    75                                                 <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( 'Public Mentions', 'buddypress' ); ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><?php printf( __( '<span>%s new</span>', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) ?></strong><?php endif; ?></a></li>
     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( 'Public Mentions', 'buddypress' ); ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><?php printf( __( '<span>%s new</span>', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) ?></strong><?php endif; ?></a></li>
     78
     79                                                <?php endif; ?>
     80
    7781                                        <?php endif; ?>
    7882
    7983                                        <?php do_action( 'bp_activity_type_tabs' ) ?>
     
    8791                                        <?php do_action( 'bp_activity_syndication_options' ) ?>
    8892
    8993                                        <li id="activity-filter-select" class="last">
    90                                                 <label for="activity-filter-by"><?php _e( 'Show:', 'buddypress' ); ?></label> 
     94                                                <label for="activity-filter-by"><?php _e( 'Show:', 'buddypress' ); ?></label>
    9195                                                <select id="activity-filter-by">
    9296                                                        <option value="-1"><?php _e( 'Everything', 'buddypress' ) ?></option>
    9397                                                        <option value="activity_update"><?php _e( 'Updates', 'buddypress' ) ?></option>
  • bp-themes/bp-default/functions.php

     
    104104                        add_action( 'bp_member_header_actions',    'bp_add_friend_button' );
    105105
    106106                // Activity button
    107                 if ( bp_is_active( 'activity' ) )
     107                if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() )
    108108                        add_action( 'bp_member_header_actions',    'bp_send_public_message_button' );
    109109
    110110                // Messages button
  • bp-activity/bp-activity-actions.php

     
    297297function bp_activity_action_mentions_feed() {
    298298        global $bp, $wp_query;
    299299
    300         if ( !bp_is_current_component( 'activity' ) || !bp_is_user() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
     300        if ( !bp_activity_do_mentions() || !bp_is_current_component( 'activity' ) || !bp_is_user() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
    301301                return false;
    302302
    303303        $wp_query->is_404 = false;
  • bp-activity/bp-activity-screens.php

     
    7878 * @uses bp_activity_clear_new_mentions()
    7979 * @uses bp_is_my_profile()
    8080 */
    81 function bp_activity_reset_my_new_mentions() { 
     81function bp_activity_reset_my_new_mentions() {
    8282        if ( bp_is_my_profile() )
    8383                bp_activity_clear_new_mentions( bp_loggedin_user_id() );
    8484}
     
    9090        // No displayed user or not viewing activity component
    9191        if ( !bp_is_activity_component() )
    9292                return false;
    93        
    94         if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) ) 
    95                 return false; 
    96        
     93
     94        if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) )
     95                return false;
     96
    9797        // Get the activity details
    9898        $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true ) );
    9999
     
    158158function bp_activity_screen_notification_settings() {
    159159        global $bp;
    160160
    161         if ( !$mention = bp_get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ) )
    162                 $mention = 'yes';
     161        if ( bp_activity_do_mentions() )
     162                if ( !$mention = bp_get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ) )
     163                        $mention = 'yes';
    163164
    164165        if ( !$reply = bp_get_user_meta( $bp->displayed_user->id, 'notification_activity_new_reply', true ) )
    165166                $reply = 'yes'; ?>
     
    175176                </thead>
    176177
    177178                <tbody>
     179                        <?php if ( bp_activity_do_mentions() ) : ?>
    178180                        <tr id="activity-notification-settings-mentions">
    179181                                <td>&nbsp;</td>
    180182                                <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ?></td>
    181183                                <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
    182184                                <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
    183185                        </tr>
     186                        <?php endif; ?>
    184187                        <tr id="activity-notification-settings-replies">
    185188                                <td>&nbsp;</td>
    186189                                <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
  • bp-activity/bp-activity-loader.php

     
    128128                );
    129129
    130130                // @ mentions
    131                 $sub_nav[] = array(
    132                         'name'            => __( 'Mentions', 'buddypress' ),
    133                         'slug'            => 'mentions',
    134                         'parent_url'      => $activity_link,
    135                         'parent_slug'     => $this->slug,
    136                         'screen_function' => 'bp_activity_screen_mentions',
    137                         'position'        => 20,
    138                         'item_css_id'     => 'activity-mentions'
    139                 );
     131                if ( bp_activity_do_mentions() ) {
     132                        $sub_nav[] = array(
     133                                'name'            => __( 'Mentions', 'buddypress' ),
     134                                'slug'            => 'mentions',
     135                                'parent_url'      => $activity_link,
     136                                'parent_slug'     => $this->slug,
     137                                'screen_function' => 'bp_activity_screen_mentions',
     138                                'position'        => 20,
     139                                'item_css_id'     => 'activity-mentions'
     140                        );
     141                }
    140142
    141143                // Favorite activity items
    142144                $sub_nav[] = array(
     
    212214                        );
    213215
    214216                        // Mentions
    215                         $wp_admin_nav[] = array(
    216                                 'parent' => 'my-account-' . $this->id,
    217                                 'title'  => $title,
    218                                 'href'   => trailingslashit( $activity_link . 'mentions' )
    219                         );
     217                        if ( bp_activity_do_mentions() ) {
     218                                $wp_admin_nav[] = array(
     219                                        'parent' => 'my-account-' . $this->id,
     220                                        'title'  => $title,
     221                                        'href'   => trailingslashit( $activity_link . 'mentions' )
     222                                );
     223                        }
    220224
    221225                        // Personal
    222226                        $wp_admin_nav[] = array(
  • bp-activity/bp-activity-filters.php

     
    7373add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' );
    7474add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );
    7575
    76 add_filter( 'pre_comment_content',                   'bp_activity_at_name_filter' );
    77 add_filter( 'group_forum_topic_text_before_save',    'bp_activity_at_name_filter' );
    78 add_filter( 'group_forum_post_text_before_save',     'bp_activity_at_name_filter' );
     76if ( bp_activity_do_mentions() ) {
     77        add_filter( 'pre_comment_content',                'bp_activity_at_name_filter' );
     78        add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
     79        add_filter( 'group_forum_post_text_before_save',  'bp_activity_at_name_filter' );
     80}
    7981
    8082add_filter( 'bp_get_activity_parent_content',        'bp_create_excerpt' );
    8183
     
    112114 * @package BuddyPress Activity
    113115 *
    114116 * @param string $content The activity content
    115  * @param int $activity_id When $adjust_mention_count is true, you must provide an $activity_id, 
     117 * @param int $activity_id When $adjust_mention_count is true, you must provide an $activity_id,
    116118 *   which will be added to the list of the user's unread mentions
    117119 */
    118120function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
     
    135137                $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
    136138        }
    137139
    138         // Adjust the activity count for this item     
     140        // Adjust the activity count for this item
    139141        if ( $activity_id )
    140142                bp_activity_adjust_mention_count( $activity_id, 'add' );
    141143
    142144        return $content;
    143 } 
     145}
    144146
    145147/**
    146148 * Catch mentions in saved activity items
     
    153155function bp_activity_at_name_filter_updates( $activity ) {
    154156        // Only run this function once for a given activity item
    155157        remove_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter_updates' );
    156        
     158
    157159        // Run the content through the linking filter, making sure to increment mention count
    158160        $activity->content = bp_activity_at_name_filter( $activity->content, $activity->id );
    159        
     161
    160162        // Resave the activity with the new content
    161163        $activity->save();
    162164}
    163 add_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter_updates' );
     165if ( bp_activity_do_mentions() )
     166        add_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter_updates' );
    164167
    165168function bp_activity_make_nofollow_filter( $text ) {
    166169        return preg_replace_callback( '|<a (.+?)>|i', 'bp_activity_make_nofollow_filter_callback', $text );
     
    198201        return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
    199202}
    200203add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
    201 add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );
     204add_filter( 'bp_get_activity_content',      'bp_activity_truncate_entry', 5 );
     205
     206/**
     207 * Are mentions enabled or disabled?
     208 *
     209 * @package BuddyPress Activity
     210 * @since 1.3
     211 *
     212 * @uses apply_filters() To call 'bp_activity_do_mentions' hook.
     213 * @return bool $retval True to enable mentions, false to disable. Defaults to true.
     214 */
     215function bp_activity_do_mentions() {
     216        $retval = false;
     217
     218        return apply_filters( 'bp_activity_do_mentions', $retval );
     219}
     220
    202221?>
     222 No newline at end of file