Skip to:
Content

BuddyPress.org

Changeset 3463 for trunk/bp-loader.php


Ignore:
Timestamp:
11/21/2010 04:06:48 PM (15 years ago)
Author:
boonebgorges
Message:

Adds Upgrade routine for WP MS activation. Fixes #2732. Moves site options loading functions to ensure that they're loaded at activation. Fixes #2717, props DJPaul. Modifies the way that bp-pages data is stored in and fetched from options tables on multisite. References #2518. The only thing this patch does not do is bake pie.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-loader.php

    r3315 r3463  
    7777}
    7878
     79/**
     80 * bp_core_get_site_options()
     81 *
     82 * BuddyPress uses site options to store configuration settings. Many of these settings are needed
     83 * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
     84 * them all in one go.
     85 *
     86 * @package BuddyPress Core
     87 */
     88function bp_core_get_site_options() {
     89    global $bp, $wpdb;
     90
     91    $options = apply_filters( 'bp_core_site_options', array(
     92        'bp-deactivated-components',
     93        'bp-blogs-first-install',
     94        'bp-disable-blog-forum-comments',
     95        'bp-xprofile-base-group-name',
     96        'bp-xprofile-fullname-field-name',
     97        'bp-disable-profile-sync',
     98        'bp-disable-avatar-uploads',
     99        'bp-disable-account-deletion',
     100        'bp-disable-forum-directory',
     101        'bp-disable-blogforum-comments',
     102        'bb-config-location',
     103        'hide-loggedout-adminbar',
     104
     105        /* Useful WordPress settings used often */
     106        'user-avatar-default',
     107        'tags_blog_id',
     108        'registration',
     109        'fileupload_maxk'
     110    ) );
     111
     112    $meta_keys = "'" . implode( "','", (array)$options ) ."'";
     113
     114    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}" );
     116    else
     117        $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     118
     119    $site_options = array();
     120    if ( !empty( $meta ) ) {
     121        foreach( (array)$meta as $meta_item )
     122            $site_options[$meta_item->name] = $meta_item->value;
     123    }
     124
     125    return apply_filters( 'bp_core_get_site_options', $site_options );
     126}
     127
    79128/* Activation Function */
    80129function bp_loader_activate() {
     
    85134    if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
    86135        switch_theme( 'bp-default', 'bp-default' );
    87 
    88     /* Install site options on activation */
    89     //TODO: Find where to put this back. Here is no good because bp-core.php isn't loaded on new installation.
    90     //bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0,  'bp-disable-forum-directory' => 0,  'bp-disable-profile-sync' => 0 ) );
    91136
    92137    do_action( 'bp_loader_activate' );
     
    108153    delete_site_option( 'bp-deactivated-components' );
    109154    delete_site_option( 'bp-blogs-first-install' );
    110     delete_site_option( 'bp-pages' );
    111155
    112156    do_action( 'bp_loader_deactivate' );
Note: See TracChangeset for help on using the changeset viewer.