Skip to:
Content

bbPress.org

Changeset 3398


Ignore:
Timestamp:
08/08/2011 12:55:08 AM (10 years ago)
Author:
johnjamesjacoby
Message:

Introduce bbp_is_site_public() function, and use it to prevent BuddyPress activity stream additions for new topics and replies if entire site is private.

Location:
branches/plugin/bbp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-common-template.php

    r3386 r3398  
    3636
    3737/** is_ ***********************************************************************/
     38
     39/**
     40 * Check if current site is public
     41 *
     42 * @since bbPress (r3398)
     43 *
     44 * @global WPDB $wpdb
     45 * @param int $site_id
     46 * @return bool True if site is public, false if private
     47 */
     48function bbp_is_site_public( $site_id = 0 ) {
     49
     50    // Get the current site ID
     51    if ( empty( $site_id ) ) {
     52        global $wpdb;
     53
     54        $site_id = (int) $wpdb->blogid;
     55    }
     56
     57    // Get the site visibility setting
     58    $public = get_blog_option( $site_id, 'blog_public', 1 );
     59
     60    return (bool) apply_filters( 'bbp_is_site_public', $public, $site_id );
     61}
    3862
    3963/**
  • branches/plugin/bbp-includes/bbp-extend-buddypress.php

    r3397 r3398  
    170170     */
    171171    private function record_activity( $args = '' ) {
    172         global $bp;
    173172
    174173        // Bail if activity is not active
     
    270269            return;
    271270
     271        // Bail if site is private
     272        if ( !bbp_is_site_public() )
     273            return;
     274
    272275        // Validate activity data
    273276        $user_id  = $topic_author_id;
     
    346349            return;
    347350
     351        // Bail if site is private
     352        if ( !bbp_is_site_public() )
     353            return;
     354
    348355        // Validate activity data
    349356        $user_id  = $reply_author_id;
Note: See TracChangeset for help on using the changeset viewer.