Skip to:
Content

BuddyPress.org

Changeset 3463 for trunk/bp-core.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-core.php

    r3451 r3463  
    8383    // Set up the members id and active components entry
    8484    $bp->members->id = 'members';
     85
    8586    $bp->members->slug = $bp->pages->members->slug;
    8687    $bp->active_components[$bp->members->slug] = $bp->members->id;
     
    212213add_action( 'bp_setup_globals', 'bp_core_define_slugs' );
    213214
     215
     216/**
     217 * bp_core_get_page_meta()
     218 *
     219 * Fetches BP pages from the meta table, depending on setup
     220 *
     221 * @package BuddyPress Core Core
     222 */
     223function bp_core_get_page_meta() {
     224    if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() )
     225        $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' );
     226    else
     227        $page_ids = get_option( 'bp-pages' );
     228
     229    return $page_ids;
     230}
     231
     232/**
     233 * bp_core_update_page_meta()
     234 *
     235 * Stores BP pages in the meta table, depending on setup
     236 *
     237 * @package BuddyPress Core Core
     238 */
     239function bp_core_update_page_meta( $page_ids ) {
     240    if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() )
     241        update_blog_option( BP_ROOT_BLOG, 'bp-pages', $page_ids );
     242    else
     243        update_option( 'bp-pages', $page_ids );
     244}
     245
     246
    214247function bp_core_get_page_names() {
    215     global $wpdb, $current_blog;
    216 
    217     if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
    218         $page_ids = get_blog_option( $current_blog->blog_id, 'bp-pages' );
    219     else
    220         $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' );
     248    global $wpdb;
     249
     250    $page_ids = bp_core_get_page_meta();
    221251
    222252    if ( empty( $page_ids ) )
     
    633663 *
    634664 * @package BuddyPress Core
    635  * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
    636665 * @uses bp_core_get_userid_from_user_login() Returns the user id for the username passed
    637666 * @return The user id for the user that is currently being displayed, return zero if this is not a user home and just a normal blog.
     
    15531582
    15541583    return apply_filters( 'bp_core_get_site_path', $site_path );
    1555 }
    1556 
    1557 /**
    1558  * bp_core_get_site_options()
    1559  *
    1560  * BuddyPress uses site options to store configuration settings. Many of these settings are needed
    1561  * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
    1562  * them all in one go.
    1563  *
    1564  * @package BuddyPress Core
    1565  */
    1566 function bp_core_get_site_options() {
    1567     global $bp, $wpdb;
    1568 
    1569     $options = apply_filters( 'bp_core_site_options', array(
    1570         'bp-deactivated-components',
    1571         'bp-blogs-first-install',
    1572         'bp-disable-blog-forum-comments',
    1573         'bp-xprofile-base-group-name',
    1574         'bp-xprofile-fullname-field-name',
    1575         'bp-disable-profile-sync',
    1576         'bp-disable-avatar-uploads',
    1577         'bp-disable-account-deletion',
    1578         'bp-disable-forum-directory',
    1579         'bp-disable-blogforum-comments',
    1580         'bb-config-location',
    1581         'hide-loggedout-adminbar',
    1582 
    1583         // Useful WordPress settings used often
    1584         'avatar_default',
    1585         'tags_blog_id',
    1586         'registration',
    1587         'fileupload_maxk'
    1588     ) );
    1589 
    1590     $meta_keys = "'" . implode( "','", (array)$options ) ."'";
    1591 
    1592     if ( is_multisite() )
    1593         $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}" );
    1594     else
    1595         $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
    1596 
    1597     $site_options = array();
    1598     if ( !empty( $meta ) ) {
    1599         foreach( (array)$meta as $meta_item )
    1600             $site_options[$meta_item->name] = $meta_item->value;
    1601     }
    1602 
    1603     return apply_filters( 'bp_core_get_site_options', $site_options );
    16041584}
    16051585
     
    21642144        $new_page_ids[$slug] = wp_insert_post( array( 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );
    21652145
    2166     $page_ids = get_site_option( 'bp-pages' );
     2146    $page_ids = bp_core_get_page_meta();
     2147
    21672148    $page_ids = (array) $page_ids;
    21682149    $page_ids = array_merge( (array) $new_page_ids, (array) $page_ids );
    2169     update_site_option( 'bp-pages', $page_ids );
     2150
     2151    bp_core_update_page_meta( $page_ids );
    21702152}
    21712153?>
Note: See TracChangeset for help on using the changeset viewer.