Skip to:
Content

BuddyPress.org

Changeset 3464


Ignore:
Timestamp:
11/21/2010 04:58:53 PM (16 years ago)
Author:
boonebgorges
Message:

Modifies bp_core_get_site_options() to fetch options that are blog-specific even when Network is activated. Fixes #2756

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r3463 r3464  
    1515if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
    1616        require( WP_PLUGIN_DIR . '/bp-custom.php' );
    17 
    18 /* Define on which blog ID BuddyPress should run */
    19 if ( !defined( 'BP_ROOT_BLOG' ) )
    20         define( 'BP_ROOT_BLOG', 1 );
    2117
    2218/* Define the user and usermeta table names, useful if you are using custom or shared tables. */
  • trunk/bp-core/admin/bp-core-upgrade.php

    r3463 r3464  
    825825                        $options = array(
    826826                                'bp-db-version' => $this->current_version,
    827                                 'bp-deactivated-components' => $disabled
     827                                'bp-deactivated-components' => $disabled,
     828                                'avatar-default' => get_option( 'avatar-default' )
    828829                        );
    829830                        bp_core_activate_site_options( $options );
  • trunk/bp-core/bp-core-catchuri.php

    r3439 r3464  
    195195
    196196        // Remove the username from action variables if this is not a VHOST install
    197         if ( defined( 'VHOST' ) && 'no' == VHOST && !$is_root_component )
     197        if ( defined( 'VHOST' ) && 'no' == VHOST && empty( $is_root_component ) )
    198198                array_shift($bp_uri);
    199199
  • trunk/bp-loader.php

    r3463 r3464  
    1212define( 'BP_VERSION', '1.3-bleeding' );
    1313define( 'BP_DB_VERSION', 1225 );
     14
     15// Define on which blog ID BuddyPress should run
     16if ( !defined( 'BP_ROOT_BLOG' ) )
     17        define( 'BP_ROOT_BLOG', 1 );
    1418
    1519/***
    … …  
    8993        global $bp, $wpdb;
    9094
    91         $options = apply_filters( 'bp_core_site_options', array(
     95        // These options come from the options table in WP single, and sitemeta in MS
     96        $site_options = apply_filters( 'bp_core_site_options', array(
    9297                'bp-deactivated-components',
    9398                'bp-blogs-first-install',
    … …  
    103108                'hide-loggedout-adminbar',
    104109
    105                 /* Useful WordPress settings used often */
    106                 'user-avatar-default',
     110                // Useful WordPress settings used often
    107111                'tags_blog_id',
    108112                'registration',
    109113                'fileupload_maxk'
    110114        ) );
     115       
     116        // These options always come from the options table of BP_ROOT_BLOG
     117        $root_blog_options = apply_filters( 'bp_core_root_blog_options', array(
     118                'avatar_default'
     119        ) );
    111120
    112         $meta_keys = "'" . implode( "','", (array)$options ) ."'";
     121        $meta_keys = "'" . implode( "','", (array)$site_options ) ."'";
    113122
    114123        if ( is_multisite() )
    115                 $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
     124                $site_meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
    116125        else
    117                 $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     126                $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     127               
     128        $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'";
     129       
     130        $root_blog_meta_table = BP_ROOT_BLOG == 1 ? $wpdb->base_prefix . 'options' : $wpdb->base_prefix . BP_ROOT_BLOG . '_options';
     131        $root_blog_meta = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) );
    118132
    119133        $site_options = array();
    120         if ( !empty( $meta ) ) {
    121                 foreach( (array)$meta as $meta_item )
    122                         $site_options[$meta_item->name] = $meta_item->value;
     134        foreach( array( $site_meta, $root_blog_meta ) as $meta ) {
     135                if ( !empty( $meta ) ) {
     136                        foreach( (array)$meta as $meta_item )
     137                                $site_options[$meta_item->name] = $meta_item->value;
     138                }
    123139        }
    124 
    125140        return apply_filters( 'bp_core_get_site_options', $site_options );
    126141}
Note: See TracChangeset for help on using the changeset viewer.