Skip to:
Content

BuddyPress.org

Ticket #3261: 3261.patch

File 3261.patch, 37.0 KB (added by boonebgorges, 15 years ago)
  • bp-blogs/bp-blogs-template.php

    function bp_total_blog_count_for_user( $user_id = 0 ) {  
    362362function bp_blog_signup_enabled() {
    363363        global $bp;
    364364
    365         $active_signup = $bp->site_options['registration'];
    366 
    367         if ( !$active_signup )
    368                 $active_signup = 'all';
     365        $active_signup = isset( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : 'all';
    369366
    370367        $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
    371368
  • bp-core/admin/bp-core-admin.php

    function bp_core_admin_settings() {  
    5858
    5959                // Settings form submitted, now save the settings.
    6060                foreach ( (array)$_POST['bp-admin'] as $key => $value )
    61                         update_site_option( $key, $value );
     61                        bp_update_option( $key, $value );
    6262
    6363        } ?>
    6464
    function bp_core_admin_settings() {  
    8686                                                <tr>
    8787                                                        <th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</th>
    8888                                                        <td>
    89                                                                 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    90                                                                 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     89                                                                <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)bp_get_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     90                                                                <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)bp_get_option( 'bp-disable-profile-sync' ) || '' == bp_get_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    9191                                                        </td>
    9292                                                </tr>
    9393
    function bp_core_admin_settings() {  
    9696                                        <tr>
    9797                                                <th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th>
    9898                                                <td>
    99                                                         <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    100                                                         <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     99                                                        <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)bp_get_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     100                                                        <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)bp_get_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    101101                                                </td>
    102102                                        </tr>
    103103
    104104                                        <tr>
    105105                                                <th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th>
    106106                                                <td>
    107                                                         <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    108                                                         <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     107                                                        <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)bp_get_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     108                                                        <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    109109                                                </td>
    110110                                        </tr>
    111111
    112112                                        <tr>
    113113                                                <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
    114114                                                <td>
    115                                                         <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    116                                                         <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     115                                                        <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)bp_get_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     116                                                        <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)bp_get_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    117117                                                </td>
    118118                                        </tr>
    119119
    function bp_core_admin_settings() {  
    122122                                                <tr>
    123123                                                        <th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th>
    124124                                                        <td>
    125                                                                 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    126                                                                 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     125                                                                <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)bp_get_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     126                                                                <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)bp_get_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    127127                                                        </td>
    128128                                                </tr>
    129129
    function bp_core_admin_settings() {  
    134134                                                <tr>
    135135                                                        <th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th>
    136136                                                        <td>
    137                                                                 <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    138                                                                 <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     137                                                                <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)bp_get_option( 'bp-disable-blogforum-comments' ) || false === bp_get_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     138                                                                <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)bp_get_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    139139                                                        </td>
    140140                                                </tr>
    141141
    function bp_core_admin_settings() {  
    146146                                                <tr>
    147147                                                        <th scope="row"><?php _e( 'Restrict group creation to Site Admins?', 'buddypress' ) ?>:</th>
    148148                                                        <td>
    149                                                                 <input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php checked( '1', get_site_option( 'bp_restrict_group_creation', '0' ) ); ?>id="bp-restrict-group-creation" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    150                                                                 <input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php checked( '0', get_site_option( 'bp_restrict_group_creation', '0' ) ); ?>id="bp-restrict-group-creation" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     149                                                                <input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php checked( '1', bp_get_option( 'bp_restrict_group_creation', '0' ) ); ?>id="bp-restrict-group-creation" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     150                                                                <input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php checked( '0', bp_get_option( 'bp_restrict_group_creation', '0' ) ); ?>id="bp-restrict-group-creation" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    151151                                                        </td>
    152152                                                </tr>
    153153
    function bp_core_admin_component_setup_handler() {  
    183183                // Settings form submitted, now save the settings. First, set active components
    184184                if ( isset( $_POST['bp_components'] ) ) {
    185185                        $bp->active_components = stripslashes_deep( $_POST['bp_components'] );
    186                         update_site_option( 'bp-active-components', $bp->active_components );
     186                        bp_update_option( 'bp-active-components', $bp->active_components );
    187187                }
    188188
    189189                // Then, update the directory pages
    function bp_core_admin_component_setup() {  
    262262 */
    263263function bp_core_admin_component_options() {
    264264        global $bp_wizard;
     265                       
     266        require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
    265267
    266         $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
     268        $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    267269       
    268270        // An array of strings looped over to create component setup markup
    269271        $optional_components = array(
  • bp-core/admin/bp-core-schema.php

    function bp_core_install_extended_profiles() {  
    204204        $charset_collate = bp_core_set_charset();
    205205        $bp_prefix = bp_core_get_table_prefix();
    206206
    207         update_site_option( 'bp-xprofile-base-group-name', _x( 'Base', 'First XProfile group name', 'buddypress' ) );
    208         update_site_option( 'bp-xprofile-fullname-field-name', _x( 'Name', 'XProfile fullname field name', 'buddypress' ) );
     207        bp_update_option( 'bp-xprofile-base-group-name', _x( 'Base', 'First XProfile group name', 'buddypress' ) );
     208        bp_update_option( 'bp-xprofile-fullname-field-name', _x( 'Name', 'XProfile fullname field name', 'buddypress' ) );
    209209
    210210        $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups (
    211211                            id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    function bp_core_install_extended_profiles() {  
    262262        $insert_sql = array();
    263263
    264264        if ( !$wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_groups WHERE id = 1" ) )
    265                 $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );";
     265                $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );";
    266266
    267267        if ( !$wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) )
    268                 $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
     268                $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
    269269
    270270        dbDelta( $insert_sql );
    271271}
  • bp-core/admin/bp-core-update.php

    class BP_Core_Setup_Wizard {  
    252252        <?php
    253253        }
    254254
    255         function step_ms_update() {
     255        function step_ms_update() {                     
     256                require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
     257               
    256258                if ( !current_user_can( 'activate_plugins' ) )
    257259                        return false;
    258260
    259                 $active_components = get_site_option( 'bp-active-components' );
     261                $active_components = bp_get_option( 'bp-active-components' );
    260262
    261263                if ( defined( 'BP_BLOGS_SLUG' ) )
    262264                        $blogs_slug = constant( 'BP_BLOGS_SLUG' );
    class BP_Core_Setup_Wizard {  
    264266                        $blogs_slug = 'blogs';
    265267
    266268                // Call up old bp-pages to see if a page has been previously linked to Blogs
    267                 $page_blog_id           = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    268                 $existing_pages_data    = get_blog_option( $page_blog_id, 'bp-pages' );
    269                 $existing_pages         = $existing_pages_data[$page_blog_id];
     269                $existing_pages = bp_get_option( 'bp-pages' );
    270270
    271271                if ( !empty( $existing_pages['blogs'] ) )
    272272                        $existing_blog_page = '&selected=' . $existing_pages['blogs'];
    class BP_Core_Setup_Wizard {  
    362362                        return false;
    363363
    364364                $existing_pages = bp_core_update_get_page_meta();
     365               
     366                // Provide empty indexes to avoid PHP errors with wp_dropdown_pages()
     367                $indexes = array( 'members', 'activity', 'groups', 'forums', 'blogs', 'register', 'activate' );
     368                foreach ( $indexes as $index ) {
     369                        if ( !isset( $existing_pages[$index] ) )
     370                                $existing_pages[$index] = '';
     371                }
     372               
     373                if ( !empty( $existing_pages['blogs'] ) )
     374                        $existing_blog_page = '&selected=' . $existing_pages['blogs'];
     375                else
     376                        $existing_blog_page = '';
    365377
    366378                // Get active components
    367                 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
     379                $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    368380
    369381                // Check for defined slugs
    370382                $members_slug    = !empty( $bp->members->slug    ) ? $bp->members->slug    : __( 'members',  'buddypress' );
    class BP_Core_Setup_Wizard {  
    758770                                        switch_to_blog( BP_ROOT_BLOG );
    759771
    760772                                // Move bp-pages data from the blog options table to site options
    761                                 $page_blog_id           = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    762                                 $existing_pages_data    = get_blog_option( $page_blog_id, 'bp-pages' );
    763                                 $existing_pages         = $existing_pages_data[$page_blog_id];
     773                                $existing_pages_data    = bp_get_option( 'bp-pages' );
    764774
    765775                                $bp_pages               = $this->setup_pages( (array)$_POST['bp_pages'] );
    766776                                $bp_pages               = array_merge( (array)$existing_pages, (array)$bp_pages );
    767777
    768                                 $existing_pages_data[$page_blog_id] = $bp_pages;
    769 
    770                                 update_site_option( 'bp-pages', $existing_pages_data );
     778                                bp_update_option( 'bp-pages', $bp_pages );
    771779
    772780                                if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
    773781                                        restore_current_blog();
    class BP_Core_Setup_Wizard {  
    775783                                bp_core_install( $active_components );
    776784                        }
    777785
    778                         update_site_option( 'bp-active-components', $active_components );
     786                        bp_update_option( 'bp-active-components', $active_components );
    779787
    780788                        return true;
    781789                }
    class BP_Core_Setup_Wizard {  
    793801                        // Settings form submitted, now save the settings.
    794802                        foreach ( (array)$_POST['bp_components'] as $key => $value )
    795803                                $active_components[$key] = 1;
     804                       
     805                        require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
    796806
    797                         update_site_option( 'bp-active-components', $active_components );
     807                        bp_update_option( 'bp-active-components', $active_components );
    798808
    799809                        wp_cache_flush();
    800810                        bp_core_install();
    class BP_Core_Setup_Wizard {  
    822832                                wp_delete_post( $page_id, true );
    823833
    824834                        $blog_pages     = $this->setup_pages( (array)$_POST['bp_pages'] );
    825                         $page_blog_id   = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    826                         $bp_pages       = array( $page_blog_id => $blog_pages );
    827835
    828                         update_site_option( 'bp-pages', $bp_pages );
     836                        bp_update_option( 'bp-pages', $blog_pages );
    829837
    830838                        if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
    831839                                restore_current_blog();
    class BP_Core_Setup_Wizard {  
    9941002                        check_admin_referer( 'bpwizard_finish' );
    9951003
    9961004                        // Update the DB version in the database
     1005                        // Stored in sitemeta. Do not use bp_update_option()
    9971006                        update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) );
    9981007                        delete_site_option( 'bp-core-db-version' );
    9991008
    10001009                        // Delete the setup cookie
    10011010                        @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
    10021011
    1003                         // Load BP, so that the redirect is successful
     1012                        // Load BP and hook the admin menu, so that the redirect is successful
    10041013                        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
     1014                        bp_core_add_admin_menu();
    10051015
    10061016                        // Redirect to the BuddyPress dashboard
    10071017                        $redirect = bp_core_update_do_network_admin() ? add_query_arg( array( 'page' => 'bp-general-settings' ), network_admin_url( 'admin.php' ) ) : add_query_arg( array( 'page' => 'bp-general-settings' ), admin_url( 'admin.php' ) );
    function bp_core_install( $active_components = false ) {  
    10611071        global $wpdb;
    10621072
    10631073        if ( empty( $active_components ) )
    1064                 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
     1074                $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    10651075
    10661076        require_once( dirname( __FILE__ ) . '/bp-core-schema.php' );
    10671077
    function bp_update_db_stuff() {  
    11171127        // On first installation - record all existing blogs in the system.
    11181128        if ( !(int)$bp->site_options['bp-blogs-first-install'] && is_multisite() ) {
    11191129                bp_blogs_record_existing_blogs();
    1120                 add_site_option( 'bp-blogs-first-install', 1 );
     1130                update_site_option( 'bp-blogs-first-install', 1 );
    11211131        }
    11221132
    11231133        if ( is_multisite() )
    function bp_core_update_add_admin_menu_styles() {  
    12341244add_action( 'admin_head', 'bp_core_update_add_admin_menu_styles' );
    12351245
    12361246/**
    1237  * Fetches BP pages from the meta table, depending on setup
     1247 * Fetches BP pages from the meta table
    12381248 *
    12391249 * @package BuddyPress Core
    12401250 * @since 1.3
    12411251 *
    12421252 * @return array $page_ids
    12431253 */
    1244 function bp_core_update_get_page_meta() {
    1245         $page_ids = get_site_option( 'bp-pages' );
    1246 
    1247         $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false;
    1248 
    1249         $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG;
    1250 
    1251         $blog_page_ids = !empty( $page_ids[$page_blog_id] ) ? $page_ids[$page_blog_id] : false;
     1254function bp_core_update_get_page_meta() {                       
     1255        require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
     1256       
     1257        if ( !$page_ids = bp_get_option( 'bp-pages' ) )
     1258                $page_ids = array();
    12521259
    1253         return apply_filters( 'bp_core_update_get_page_meta', $blog_page_ids );
     1260        return apply_filters( 'bp_core_update_get_page_meta', $page_ids );
    12541261}
    12551262
    12561263function bp_core_update_do_network_admin() {
  • bp-core/bp-core-buddybar.php

    function bp_core_admin_bar() {  
    321321        if ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR )
    322322                return false;
    323323
    324         if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
     324        if ( (int)bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
    325325                return false;
    326326
    327327        $bp->doing_admin_bar = true;
    function bp_core_load_admin_bar() {  
    486486                // Keep the WP admin bar from loading
    487487                show_admin_bar( false );
    488488
    489                 if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
     489                if ( (int)bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
    490490                        return;
    491491
    492492                // Admin bar styles
  • bp-core/bp-core-functions.php

     
    11<?php
    22
    33/**
     4 * Retrieve an option
     5 *
     6 * This is a wrapper for get_blog_option(), which in turn stores settings data (such as bp-pages)
     7 * on the appropriate blog, given your current setup.
     8 *
     9 * The 'bp_get_option' filter is primarily for backward-compatibility.
     10 *
     11 * @package BuddyPress
     12 * @since 1.3
     13 *
     14 * @uses bp_get_option_blog_id()
     15 * @param str $option_name The option to be retrieved
     16 * @param str $default Optional. Default value to be returned if the option isn't set
     17 * @return mixed The value for the option
     18 */
     19function bp_get_option( $option_name, $default = false ) {
     20        $value = get_blog_option( bp_get_option_blog_id( $option_name ), $option_name, $default );
     21       
     22        return apply_filters( 'bp_get_option', $value );
     23}
     24
     25/**
     26 * Save an option
     27 *
     28 * This is a wrapper for update_blog_option(), which in turn stores settings data (such as bp-pages)
     29 * on the appropriate blog, given your current setup.
     30 *
     31 * @package BuddyPress
     32 * @since 1.3
     33 *
     34 * @uses bp_get_option_blog_id()
     35 * @param str $option_name The option key to be set
     36 * @param str $value The value to be set
     37 */
     38function bp_update_option( $option_name, $value ) {
     39        // update_blog_option() does not return anything on success/failure, so neither can we
     40        update_blog_option( bp_get_option_blog_id( $option_name ), $option_name, $value );
     41}
     42
     43/**
     44 * Delete an option
     45 *
     46 * This is a wrapper for delete_blog_option(), which in turn deletes settings data (such as
     47 * bp-pages) on the appropriate blog, given your current setup.
     48 *
     49 * @package BuddyPress
     50 * @since 1.3
     51 *
     52 * @uses bp_get_option_blog_id()
     53 * @param str $option_name The option key to be set
     54 */
     55function bp_delete_option( $option_name ) {
     56        // update_blog_option() does not return anything on success/failure, so neither can we
     57        delete_blog_option( bp_get_option_blog_id( $option_name ), $option_name );
     58}
     59
     60/**
     61 * Retrieve the filterable blog_id of the blog where the option is question is saved
     62 *
     63 * @package BuddyPress
     64 * @since 1.3
     65 *
     66 * @see bp_get_option()
     67 * @see bp_update_option()
     68 * @uses apply_filters() Filter bp_get_option_blog_id to change this setting
     69 * @return int $blog_id
     70 */
     71function bp_get_option_blog_id( $option_name ) {
     72        $blog_specific_options = apply_filters( 'bp_blog_specific_options', array(
     73                'bp-pages'
     74        ) );
     75       
     76        if ( in_array( $option_name, $blog_specific_options ) ) {
     77                if ( defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ) {
     78                        $blog_id = get_current_blog_id();
     79                } else {
     80                        $blog_id = BP_ROOT_BLOG;
     81                }
     82        } else {
     83                $blog_id = BP_ROOT_BLOG;
     84        }
     85
     86        return apply_filters( 'bp_get_option_blog_id', $blog_id );
     87}
     88
     89/**
    490 * Allow filtering of database prefix. Intended for use in multinetwork installations.
    591 *
    692 * @global object $wpdb WordPress database object
    function bp_core_get_table_prefix() {  
    22108 *       people running trunk installations. Leave for a version or two, then remove.
    23109 */
    24110function bp_core_get_page_meta() {
    25         $page_ids = get_site_option( 'bp-pages' );
    26        
    27         $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false;
    28 
    29         $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG;
     111        $page_ids = bp_get_option( 'bp-pages' );
    30112
    31113        // Upgrading from an earlier version of BP pre-1.3
    32         if ( empty( $page_ids ) || isset( $page_ids['members'] ) ) {           
    33                 if ( empty( $page_ids ) ) {             
    34                         // We're probably coming from an old multisite install
    35                         $old_page_ids = get_blog_option( $page_blog_id, 'bp-pages' );
    36                 } else {
    37                         // We're probably coming from an old single-WP install
    38                         $old_page_ids = $page_ids;
    39                 }
    40                
    41                 /**
    42                  * If $page_ids is found in a blog_option, and it's formatted in the new way (keyed
    43                  * by blog_id), it means that this is an MS upgrade. Return false and let the
    44                  * upgrade wizard handle the migration.
    45                  */
    46                 if ( !isset( $old_page_ids['members'] ) )
    47                         return false;
    48                        
    49                 // Finally, move the page ids over to site options
    50                 $new_page_ids = array(
    51                         $page_blog_id => $old_page_ids
    52                 );
     114        if ( !isset( $page_ids['members'] ) && $ms_page_ids = get_site_option( 'bp-pages' ) ) {
     115                $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false;
    53116
    54                 update_site_option( 'bp-pages', $new_page_ids );
     117                $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG;
     118               
     119                if ( isset( $ms_page_ids[$page_blog_id] ) ) {
     120                        $page_ids = $ms_page_ids[$page_blog_id];
     121               
     122                        bp_update_option( 'bp-pages', $page_ids );
     123                }
    55124        }
    56125       
    57         $blog_page_ids = !empty( $page_ids[$page_blog_id] ) ? $page_ids[$page_blog_id] : false;
    58        
    59         return apply_filters( 'bp_core_get_page_meta', $blog_page_ids );
     126        return apply_filters( 'bp_core_get_page_meta', $page_ids );
    60127}
    61128
    62129/**
    63  * Stores BP pages in the meta table, depending on setup
    64  *
    65  * bp-pages data is stored in site_options (falls back to options on non-MS), in an array keyed by
    66  * blog_id. This allows you to change your BP_ROOT_BLOG and go through the setup process again.
     130 * Stores BP pages in the meta table
    67131 *
    68132 * @package BuddyPress Core
    69133 * @since 1.3
    function bp_core_get_page_meta() {  
    71135 * @param array $blog_page_ids The IDs of the WP pages corresponding to BP component directories
    72136 */
    73137function bp_core_update_page_meta( $blog_page_ids ) {
    74         if ( !$page_ids = get_site_option( 'bp-pages' ) )
    75                 $page_ids = array();
    76 
    77         // Generally, we key by the BP_ROOT_BLOG. Exception: when BP_ENABLE_MULTIBLOG is turned on
    78         $key = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    79        
    80         $page_ids[$key] = $blog_page_ids;
    81 
    82         update_site_option( 'bp-pages', $page_ids );
     138        bp_update_option( 'bp-pages', $blog_page_ids );
    83139}
    84140
    85141/**
    add_action( 'bp_init', 'bp_core_add_ajax_hook' );  
    874930 * site options.
    875931 *
    876932 * @package BuddyPress Core
     933 * @todo Does this need to be here anymore after the introduction of bp_get_option etc?
    877934 */
    878935function bp_core_activate_site_options( $keys = array() ) {
    879936        global $bp;
    function bp_core_activate_site_options( $keys = array() ) {  
    883940
    884941                foreach ( $keys as $key => $default ) {
    885942                        if ( empty( $bp->site_options[ $key ] ) ) {
    886                                 $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
     943                                $bp->site_options[ $key ] = bp_get_option( $key, $default );
    887944
    888                                 if ( !update_site_option( $key, $bp->site_options[ $key ] ) )
     945                                if ( !bp_update_option( $key, $bp->site_options[ $key ] ) )
    889946                                        $errors = true;
    890947                        }
    891948                }
    function bp_core_activate_site_options( $keys = array() ) {  
    907964function bp_core_get_site_options() {
    908965        global $bp, $wpdb;
    909966
    910         // These options come from the options table in WP single, and sitemeta in MS
     967        // These options come from the options table
    911968        $site_options = apply_filters( 'bp_core_site_options', array(
    912969                'bp-deactivated-components',
    913970                'bp-blogs-first-install',
    function bp_core_get_site_options() {  
    935992
    936993        $meta_keys = "'" . implode( "','", (array)$site_options ) ."'";
    937994
    938         if ( is_multisite() )
    939                 $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}" );
    940         else
    941                 $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     995        $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     996       
     997        // Backward compatibility - moves sitemeta to the blog
     998        if ( empty( $site_meta ) || ( count( $site_meta ) < count( $site_options ) ) ) {
     999                if ( is_multisite() ) {
     1000                        $ms_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}" );
     1001                } else {
     1002                        $ms_site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     1003                }
     1004               
     1005                $settings_to_move = array(
     1006                        'bp-deactivated-components',
     1007                        'bp-blogs-first-install',
     1008                        'bp-disable-blog-forum-comments',
     1009                        'bp-xprofile-base-group-name',
     1010                        'bp-xprofile-fullname-field-name',
     1011                        'bp-disable-profile-sync',
     1012                        'bp-disable-avatar-uploads',
     1013                        'bp-disable-account-deletion',
     1014                        'bp-disable-forum-directory',
     1015                        'bp-disable-blogforum-comments',
     1016                        'bb-config-location',
     1017                        'hide-loggedout-adminbar',
     1018                );
     1019               
     1020                foreach( (array)$ms_site_meta as $meta ) {     
     1021                        if ( isset( $meta->name ) && in_array( $meta->name, $settings_to_move ) ) {
     1022                                bp_update_option( $meta->name, $meta->value );
     1023                                               
     1024                                if ( empty( $site_meta[$meta->name] ) ) {
     1025                                        $site_meta[$meta->name] = $meta->value;
     1026                                }
     1027                        }
     1028                }
     1029        }
    9421030
    9431031        $root_blog_meta_keys  = "'" . implode( "','", (array)$root_blog_options ) ."'";
    9441032        $root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options';
    function bp_core_get_site_options() {  
    9481036        foreach( array( $site_meta, $root_blog_meta ) as $meta ) {
    9491037                if ( !empty( $meta ) ) {
    9501038                        foreach( (array)$meta as $meta_item ) {
    951                                 $site_options[$meta_item->name] = $meta_item->value;
     1039                                if ( isset( $meta_item->name ) )
     1040                                        $site_options[$meta_item->name] = $meta_item->value;
    9521041                        }
    9531042                }
    9541043        }
  • bp-core/bp-core-loader.php

    require_once( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php' );  
    2121if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
    2222        require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php'  );
    2323
     24// Move active components from sitemeta, if necessary
     25// Provides backpat with earlier versions of BP
     26if ( is_multisite() && $active_components = get_site_option( 'bp-active-components' ) )
     27        bp_update_option( 'bp-active-components', $active_components );
     28
    2429/** "And now for something completely different" ******************************/
    2530
    2631class BP_Core extends BP_Component {
    class BP_Core extends BP_Component {  
    6065                $bp->required_components    = apply_filters( 'bp_required_components',    array( 'members', ) );
    6166
    6267                // Get a list of activated components
    63                 if ( $active_components = get_site_option( 'bp-active-components' ) ) {
     68                if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
    6469                        $bp->active_components      = apply_filters( 'bp_active_components',      $active_components );
    6570                        $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
    6671
    6772                // Pre 1.3 Backwards compatibility
    68                 } elseif ( $deactivated_components = get_site_option( 'bp-deactivated-components' ) ) {
     73                } elseif ( $deactivated_components = bp_get_option( 'bp-deactivated-components' ) ) {
    6974                        // Trim off namespace and filename
    7075                        foreach ( $deactivated_components as $component => $value )
    7176                                $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
  • bp-core/bp-core-template.php

    function bp_registration_needs_activation() {  
    538538        return apply_filters( 'bp_registration_needs_activation', true );
    539539}
    540540
    541 function bp_get_option( $option_name ) {
    542         global $bp;
    543 
    544         if ( !empty( $bp->site_options[$option_name] ) )
    545                 $retval = $bp->site_options[$option_name];
    546         else
    547                 $retval = false;
    548 
    549         return apply_filters( 'bp_get_option', $retval );
    550 }
    551 
    552541/**
    553542 * Allow templates to pass parameters directly into the template loops via AJAX
    554543 *
  • bp-core/bp-core-wpabstraction.php

    if ( !is_multisite() ) {  
    1616        global $wpdb;
    1717
    1818        $wpdb->base_prefix = $wpdb->prefix;
    19         $wpdb->blogid      = 1;
     19        $wpdb->blogid      = BP_ROOT_BLOG;
    2020
    2121        if ( !function_exists( 'get_blog_option' ) ) {
    2222                function get_blog_option( $blog_id, $option_name, $default = false ) {
    2323                        return get_option( $option_name, $default );
    2424                }
    2525        }
     26       
     27        if ( !function_exists( 'update_blog_option' ) ) {
     28                function update_blog_option( $blog_id, $option_name, $value ) {
     29                        return update_option( $option_name, $value );
     30                }
     31        }
    2632
    2733        if ( !function_exists( 'switch_to_blog' ) ) {
    2834                function switch_to_blog() {
  • bp-forums/bp-forums-admin.php

    function bp_forums_configure_existing_install() {  
    143143                $_REQUEST['bbconfigloc'] .= 'bb-config.php';
    144144        }
    145145
    146         update_site_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );
     146        bp_update_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );
    147147
    148148        if ( !file_exists( $_REQUEST['bbconfigloc'] ) )
    149149                return false;
    function bp_forums_bbpress_install() {  
    214214                $initial_write = $file;
    215215        }
    216216
    217         update_site_option( 'bb-config-location', ABSPATH . 'bb-config.php' );
     217        bp_update_option( 'bb-config-location', ABSPATH . 'bb-config.php' );
    218218        return $initial_write;
    219219}
    220220
  • bp-groups/bp-groups-template.php

    function bp_group_member_admin_pagination() {  
    17401740 * @since BuddyPress 1.3
    17411741 *
    17421742 * @uses apply_filters() To call 'bp_user_can_create_groups'.
    1743  * @uses get_site_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0.
     1743 * @uses bp_get_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0.
    17441744 * @uses is_super_admin() To determine if current user if super admin.
    17451745 *
    17461746 * @return bool True if user can create groups. False otherwise.
    function bp_user_can_create_groups() {  
    17511751                return true;
    17521752
    17531753        // Get group creation option, default to 0 (allowed)
    1754         $restricted = (int) get_site_option( 'bp_restrict_group_creation', 0 );
     1754        $restricted = (int) bp_get_option( 'bp_restrict_group_creation', 0 );
    17551755
    17561756        // Allow by default
    17571757        $can_create = true;
  • bp-members/bp-members-functions.php

    function bp_core_get_all_posts_for_user( $user_id = 0 ) {  
    535535 * @uses is_super_admin() Checks to see if the user is a site administrator.
    536536 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs.
    537537 * @uses wp_delete_user() Deletes a user from the system on singlesite installs.
    538  * @uses get_site_option Checks if account deletion is allowed
    539538 */
    540539function bp_core_delete_account( $user_id = 0 ) {
    541540        global $bp, $wp_version;
  • bp-xprofile/bp-xprofile-admin.php

    function xprofile_admin( $message = '', $type = 'error' ) {  
    4949                </h2>
    5050
    5151                <p><?php _e( 'Your users will distinguish themselves through their profile page. You must give them profile fields that allow them to describe themselves in a way that is relevant to the theme of your social network.', 'buddypress'); ?></p>
    52                 <p><?php echo sprintf( __( 'NOTE: Any fields in the "%s" group will appear on the signup page.', 'buddypress' ), esc_html( stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) ) ?></p>
     52                <p><?php echo sprintf( __( 'NOTE: Any fields in the "%s" group will appear on the signup page.', 'buddypress' ), esc_html( stripslashes( bp_get_option( 'bp-xprofile-base-group-name' ) ) ) ) ?></p>
    5353
    5454                <form action="" id="profile-field-form" method="post">
    5555