Skip to:
Content

BuddyPress.org

Ticket #3388: 3388.002.diff

File 3388.002.diff, 14.6 KB (added by cnorris23, 14 years ago)

admin option

  • 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-core/admin/bp-core-admin.php

     
    1818 * @package BuddyPress Core
    1919 * @since {@internal Unknown}}
    2020 */
    21 function bp_core_admin_dashboard() { 
     21function bp_core_admin_dashboard() {
    2222        $base_url = bp_get_admin_url( 'admin.php' );
    2323        $action   = add_query_arg( array( 'page' => 'bp-general-settings' ), $base_url );
    2424        ?>
     
    136136                                                        </td>
    137137                                                </tr>
    138138
     139                                                <tr>
     140                                                        <th scope="row"><?php _e( 'Disable activity @mentions?', 'buddypress' ) ?>:</th>
     141                                                        <td>
     142                                                                <input type="radio" name="bp-admin[bp_disable_mentions]"<?php checked( '1', bp_get_option( 'bp_disable_mentions', '0' ) ); ?>id="bp_disable_mentions" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     143                                                                <input type="radio" name="bp-admin[bp_disable_mentions]"<?php checked( '0', bp_get_option( 'bp_disable_mentions', '0' ) ); ?>id="bp_disable_mentions" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     144                                                        </td>
     145                                                </tr>
     146
    139147                                        <?php endif; ?>
    140148
    141149                                        <?php if ( bp_is_active( 'groups' ) ) : ?>
     
    330338 */
    331339function bp_core_admin_component_options() {
    332340        global $bp_wizard;
    333        
     341
    334342        // Load core functions, if needed
    335343        if ( !function_exists( 'bp_get_option' ) )
    336344                require( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
    337345
    338346        $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    339        
     347
    340348        // An array of strings looped over to create component setup markup
    341349        $optional_components = apply_filters( 'bp_admin_optional_components', array(
    342350                'xprofile' => array(
     
    387395                        'description' => __( 'Everything in a BuddyPress community revolves around its members.', 'buddypress' )
    388396                ),
    389397        ) );
    390        
     398
    391399        // On new install, set all components to be active by default
    392400        if ( !empty( $bp_wizard ) && 'install' == $bp_wizard->setup_type && empty( $active_components ) )
    393401                $active_components = $optional_components;
    394402
    395403        ?>
    396        
     404
    397405        <?php /* The setup wizard uses different, more descriptive text here */ ?>
    398406        <?php if ( empty( $bp_wizard ) ) : ?>
    399407
    400408                <h3><?php _e( 'Available Components', 'buddypress' ); ?></h3>
    401                                
     409
    402410                <p><?php _e( 'Each component has a unique purpose, and your community may not need each one.', 'buddypress' ); ?></p>
    403411
    404412        <?php endif ?>
    405        
     413
    406414        <table class="form-table">
    407415                <tbody>
    408416
     
    479487 */
    480488function bp_core_admin_page_options() {
    481489        global $bp;
    482        
     490
    483491        // Get the existing WP pages
    484492        $existing_pages = bp_core_get_page_meta();
    485493
     
    493501
    494502        if ( is_multisite() )
    495503                $directory_pages['blogs'] = __( "Site Directory", 'buddypress' ); ?>
    496        
     504
    497505        <h3><?php _e( 'Directories', 'buddypress' ); ?></h3>
    498        
     506
    499507        <p><?php _e( 'Choose a WordPress Page to associate with each available BuddyPress Component directory.', 'buddypress' ); ?></p>
    500508
    501509        <table class="form-table">
     
    503511
    504512                        <?php foreach ( $directory_pages as $name => $label ) : ?>
    505513                                <?php $disabled = !bp_is_active( $name ) ? ' disabled="disabled"' : ''; ?>
    506                                
     514
    507515                                <tr valign="top">
    508516                                        <th scope="row">
    509517                                                <label for="bp_pages[<?php echo esc_attr( $name ) ?>]"><?php echo esc_html( $label ) ?><?php if ( !bp_is_active( $name ) ) : ?> <span class="description">(deactivated)</span><?php endif ?></label>
    510518                                        </th>
    511519
    512520                                        <td>
    513                                                 <?php if ( !bp_is_root_blog() ) 
     521                                                <?php if ( !bp_is_root_blog() )
    514522                                                        switch_to_blog( bp_get_root_blog_id() ) ?>
    515                                                
     523
    516524                                                <?php echo wp_dropdown_pages( array(
    517525                                                        'name'             => 'bp_pages[' . esc_attr( $name ) . ']',
    518526                                                        'echo'             => false,
     
    528536                                                        <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View' ); ?></a>
    529537
    530538                                                <?php endif; ?>
    531                                                
    532                                                 <?php if ( !bp_is_root_blog() ) 
     539
     540                                                <?php if ( !bp_is_root_blog() )
    533541                                                        restore_current_blog() ?>
    534542
    535543                                        </td>
     
    542550
    543551                </tbody>
    544552        </table>
    545        
     553
    546554        <?php
    547555
    548556        // Static pages
  • 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        // Default to true
     217        $retval = true;
     218
     219        // Get @mentions option, default to 0 (use them)
     220        $disabled = (int) bp_get_option( 'bp_disable_mentions', 0 );
     221
     222        // Turn them off?
     223        if ( $disabled )
     224                $retval = false;
     225
     226        return apply_filters( 'bp_activity_do_mentions', $retval );
     227}
     228
    202229?>
     230 No newline at end of file