Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/24/2011 06:57:51 PM (15 years ago)
Author:
boonebgorges
Message:

Introduces bp_x_option() wrapper functions, along with bp_get_option_blog_id() to allow for fully filterable option storage. Refactors internal option storage to use new API functions. Fixes bp-pages for BP_ENABLE_MULTIBLOG. Fixes #3261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/admin/bp-core-update.php

    r4556 r4559  
    1818
    1919                // Ensure that we have access to some utility functions
    20                 include( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
     20                require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
    2121
    2222                // Get current DB version
     
    260260        }
    261261
    262         function step_ms_update() {
     262        function step_ms_update() {             
    263263                if ( !current_user_can( 'activate_plugins' ) )
    264264                        return false;
    265265
    266                 $active_components = get_site_option( 'bp-active-components' );
     266                $active_components = bp_get_option( 'bp-active-components' );
    267267
    268268                if ( defined( 'BP_BLOGS_SLUG' ) )
     
    272272
    273273                // Call up old bp-pages to see if a page has been previously linked to Blogs
    274                 $page_blog_id        = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    275                 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' );
    276                 $existing_pages      = $existing_pages_data[$page_blog_id];
     274                $existing_pages = bp_get_option( 'bp-pages' );
    277275
    278276                if ( !empty( $existing_pages['blogs'] ) )
     
    370368
    371369                $existing_pages = bp_core_update_get_page_meta();
     370               
     371                // Provide empty indexes to avoid PHP errors with wp_dropdown_pages()
     372                $indexes = array( 'members', 'activity', 'groups', 'forums', 'blogs', 'register', 'activate' );
     373                foreach ( $indexes as $index ) {
     374                        if ( !isset( $existing_pages[$index] ) )
     375                                $existing_pages[$index] = '';
     376                }
     377               
     378                if ( !empty( $existing_pages['blogs'] ) )
     379                        $existing_blog_page = '&selected=' . $existing_pages['blogs'];
     380                else
     381                        $existing_blog_page = '';
    372382
    373383                // Get active components
    374                 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
     384                $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    375385
    376386                // Check for defined slugs
     
    739749                        // Update the active components option early if we're updating
    740750                        if ( 'update' == $this->setup_type )
    741                                 update_site_option( 'bp-active-components', $bp->active_components );
     751                                bp_update_option( 'bp-active-components', $bp->active_components );
    742752
    743753                        return true;
     
    772782
    773783                                // Move bp-pages data from the blog options table to site options
    774                                 $page_blog_id        = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    775                                 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' );
    776                                 $existing_pages      = $existing_pages_data[$page_blog_id];
    777 
    778                                 $bp_pages            = $this->setup_pages( (array)$_POST['bp_pages'] );
    779                                 $bp_pages            = array_merge( (array)$existing_pages, (array)$bp_pages );
    780 
    781                                 $existing_pages_data[$page_blog_id] = $bp_pages;
    782 
    783                                 update_site_option( 'bp-pages', $existing_pages_data );
     784                                $existing_pages = bp_get_option( 'bp-pages' );
     785
     786                                $bp_pages       = $this->setup_pages( (array)$_POST['bp_pages'] );
     787                                $bp_pages       = array_merge( (array)$existing_pages, (array)$bp_pages );
     788
     789                                bp_update_option( 'bp-pages', $existing_pages );
    784790
    785791                                if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
     
    789795                        }
    790796
    791                         update_site_option( 'bp-active-components', $active_components );
     797                        bp_update_option( 'bp-active-components', $active_components );
    792798
    793799                        return true;
     
    808814                                $active_components[$key] = 1;
    809815
    810                         update_site_option( 'bp-active-components', $active_components );
     816                        bp_update_option( 'bp-active-components', $active_components );
    811817
    812818                        wp_cache_flush();
     
    836842
    837843                        $blog_pages   = $this->setup_pages( (array)$_POST['bp_pages'] );
    838                         $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    839                         $bp_pages     = array( $page_blog_id => $blog_pages );
    840 
    841                         update_site_option( 'bp-pages', $bp_pages );
     844                        bp_update_option( 'bp-pages', $blog_pages );
    842845
    843846                        if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
     
    10081011
    10091012                        // Update the DB version in the database
     1013                        // Stored in sitemeta. Do not use bp_update_option()
    10101014                        update_site_option( 'bp-db-version', $this->new_version );
    10111015                        delete_site_option( 'bp-core-db-version' );
     
    10761080
    10771081        if ( empty( $active_components ) )
    1078                 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
     1082                $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    10791083
    10801084        require_once( dirname( __FILE__ ) . '/bp-core-schema.php' );
     
    11321136        if ( !(int)$bp->site_options['bp-blogs-first-install'] && is_multisite() ) {
    11331137                bp_blogs_record_existing_blogs();
    1134                 add_site_option( 'bp-blogs-first-install', 1 );
     1138                bp_update_option( 'bp-blogs-first-install', 1 );
    11351139        }
    11361140
     
    12491253
    12501254/**
    1251  * Fetches BP pages from the meta table, depending on setup
     1255 * Fetches BP pages from the meta table
    12521256 *
    12531257 * @package BuddyPress Core
     
    12561260 * @return array $page_ids
    12571261 */
    1258 function bp_core_update_get_page_meta() {
    1259         $page_ids = get_site_option( 'bp-pages' );
    1260 
    1261         $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false;
    1262 
    1263         $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG;
    1264 
    1265         $blog_page_ids = !empty( $page_ids[$page_blog_id] ) ? $page_ids[$page_blog_id] : false;
    1266 
    1267         return apply_filters( 'bp_core_update_get_page_meta', $blog_page_ids );
     1262function bp_core_update_get_page_meta() {                       
     1263        require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
     1264       
     1265        if ( !$page_ids = bp_get_option( 'bp-pages' ) )
     1266                $page_ids = array();
     1267
     1268        return apply_filters( 'bp_core_update_get_page_meta', $page_ids );
    12681269}
    12691270
Note: See TracChangeset for help on using the changeset viewer.