Changeset 4559
- Timestamp:
- 06/24/2011 06:57:51 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-template.php
r4466 r4559 363 363 global $bp; 364 364 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'; 369 366 370 367 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user" -
trunk/bp-core/admin/bp-core-admin.php
r4482 r4559 59 59 // Settings form submitted, now save the settings. 60 60 foreach ( (array)$_POST['bp-admin'] as $key => $value ) 61 update_site_option( $key, $value );61 bp_update_option( $key, $value ); 62 62 63 63 } ?> … … 87 87 <th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</th> 88 88 <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' ) ?> 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' ) ?> 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' ) ?> 91 91 </td> 92 92 </tr> … … 97 97 <th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th> 98 98 <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' ) ?> 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' ) ?> 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' ) ?> 101 101 </td> 102 102 </tr> … … 105 105 <th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th> 106 106 <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' ) ?> 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' ) ?> 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' ) ?> 109 109 </td> 110 110 </tr> … … 113 113 <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th> 114 114 <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' ) ?> 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' ) ?> 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' ) ?> 117 117 </td> 118 118 </tr> … … 123 123 <th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th> 124 124 <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' ) ?> 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' ) ?> 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' ) ?> 127 127 </td> 128 128 </tr> … … 135 135 <th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th> 136 136 <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' ) ?> 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' ) ?> 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' ) ?> 139 139 </td> 140 140 </tr> … … 147 147 <th scope="row"><?php _e( 'Restrict group creation to Site Admins?', 'buddypress' ) ?>:</th> 148 148 <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' ) ?> 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' ) ?> 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' ) ?> 151 151 </td> 152 152 </tr> … … 184 184 if ( isset( $_POST['bp_components'] ) ) { 185 185 $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 ); 187 187 } 188 188 … … 263 263 function bp_core_admin_component_options() { 264 264 global $bp_wizard; 265 266 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) ); 265 266 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 267 268 $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) ); 267 269 268 270 // An array of strings looped over to create component setup markup -
trunk/bp-core/admin/bp-core-schema.php
r4391 r4559 205 205 $bp_prefix = bp_core_get_table_prefix(); 206 206 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' ) ); 209 209 210 210 $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups ( … … 263 263 264 264 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 );"; 266 266 267 267 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 );"; 269 269 270 270 dbDelta( $insert_sql ); -
trunk/bp-core/admin/bp-core-update.php
r4556 r4559 18 18 19 19 // 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' ); 21 21 22 22 // Get current DB version … … 260 260 } 261 261 262 function step_ms_update() { 262 function step_ms_update() { 263 263 if ( !current_user_can( 'activate_plugins' ) ) 264 264 return false; 265 265 266 $active_components = get_site_option( 'bp-active-components' );266 $active_components = bp_get_option( 'bp-active-components' ); 267 267 268 268 if ( defined( 'BP_BLOGS_SLUG' ) ) … … 272 272 273 273 // 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' ); 277 275 278 276 if ( !empty( $existing_pages['blogs'] ) ) … … 370 368 371 369 $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 = ''; 372 382 373 383 // 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' ) ); 375 385 376 386 // Check for defined slugs … … 739 749 // Update the active components option early if we're updating 740 750 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 ); 742 752 743 753 return true; … … 772 782 773 783 // 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 ); 784 790 785 791 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) … … 789 795 } 790 796 791 update_site_option( 'bp-active-components', $active_components );797 bp_update_option( 'bp-active-components', $active_components ); 792 798 793 799 return true; … … 808 814 $active_components[$key] = 1; 809 815 810 update_site_option( 'bp-active-components', $active_components );816 bp_update_option( 'bp-active-components', $active_components ); 811 817 812 818 wp_cache_flush(); … … 836 842 837 843 $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 ); 842 845 843 846 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) … … 1008 1011 1009 1012 // Update the DB version in the database 1013 // Stored in sitemeta. Do not use bp_update_option() 1010 1014 update_site_option( 'bp-db-version', $this->new_version ); 1011 1015 delete_site_option( 'bp-core-db-version' ); … … 1076 1080 1077 1081 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' ) ); 1079 1083 1080 1084 require_once( dirname( __FILE__ ) . '/bp-core-schema.php' ); … … 1132 1136 if ( !(int)$bp->site_options['bp-blogs-first-install'] && is_multisite() ) { 1133 1137 bp_blogs_record_existing_blogs(); 1134 add_site_option( 'bp-blogs-first-install', 1 );1138 bp_update_option( 'bp-blogs-first-install', 1 ); 1135 1139 } 1136 1140 … … 1249 1253 1250 1254 /** 1251 * Fetches BP pages from the meta table , depending on setup1255 * Fetches BP pages from the meta table 1252 1256 * 1253 1257 * @package BuddyPress Core … … 1256 1260 * @return array $page_ids 1257 1261 */ 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 ); 1262 function 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 ); 1268 1269 } 1269 1270 -
trunk/bp-core/bp-core-buddybar.php
r4466 r4559 322 322 return false; 323 323 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() ) 325 325 return false; 326 326 … … 487 487 show_admin_bar( false ); 488 488 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() ) 490 490 return; 491 491 -
trunk/bp-core/bp-core-functions.php
r4558 r4559 1 1 <?php 2 3 /** 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 */ 19 function 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 */ 38 function 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 */ 55 function 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 * Since BP 1.3, BuddyPress has stored all of its settings in blog options tables, as opposed to 64 * sitemeta. This makes it easier for non-standard setups (like BP_ENABLE_MULTIBLOG and 65 * multinetwork BP) to save and access options in a consistent and logical way. 66 * 67 * By default, nearly all settings are stored in the options table of BP_ROOT_BLOG. The one 68 * exception is when BP_ENABLE_MULTIBLOG is enabled. In this case, bp-pages - the list of pages that 69 * are associated with BP top-level components - must be specific to each blog in the network. If 70 * you are building a plugin that requires an option (either a BP-native option, or your own custom 71 * option) to be specific to each blog in a network, filter 'bp_blog_specific_options' and add your 72 * option's name. This will allow you to use bp_get_option() and bp_update_option() seamlessly. 73 * 74 * @package BuddyPress 75 * @since 1.3 76 * 77 * @see bp_get_option() 78 * @see bp_update_option() 79 * @uses apply_filters() Filter bp_get_option_blog_id to change this setting 80 * @return int $blog_id 81 */ 82 function bp_get_option_blog_id( $option_name ) { 83 $blog_specific_options = apply_filters( 'bp_blog_specific_options', array( 84 'bp-pages' 85 ) ); 86 87 if ( in_array( $option_name, $blog_specific_options ) ) { 88 if ( defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ) { 89 $blog_id = get_current_blog_id(); 90 } else { 91 $blog_id = BP_ROOT_BLOG; 92 } 93 } else { 94 $blog_id = BP_ROOT_BLOG; 95 } 96 97 return apply_filters( 'bp_get_option_blog_id', $blog_id ); 98 } 2 99 3 100 /** … … 23 120 */ 24 121 function 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; 30 31 // 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 ); 53 54 update_site_option( 'bp-pages', $new_page_ids ); 55 } 56 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 ); 122 $page_ids = bp_get_option( 'bp-pages' ); 123 124 // Upgrading from an earlier version of BP pre-1.3 125 if ( !isset( $page_ids['members'] ) && $ms_page_ids = get_site_option( 'bp-pages' ) ) { 126 $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false; 127 128 $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG; 129 130 if ( isset( $ms_page_ids[$page_blog_id] ) ) { 131 $page_ids = $ms_page_ids[$page_blog_id]; 132 133 bp_update_option( 'bp-pages', $page_ids ); 134 } 135 } 136 137 return apply_filters( 'bp_core_get_page_meta', $page_ids ); 60 138 } 61 139 … … 72 150 */ 73 151 function 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 ); 152 bp_update_option( 'bp-pages', $blog_page_ids ); 83 153 } 84 154 … … 875 945 * 876 946 * @package BuddyPress Core 947 * @todo Does this need to be here anymore after the introduction of bp_get_option etc? 877 948 */ 878 949 function bp_core_activate_site_options( $keys = array() ) { … … 884 955 foreach ( $keys as $key => $default ) { 885 956 if ( empty( $bp->site_options[ $key ] ) ) { 886 $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG,$key, $default );887 888 if ( ! update_site_option( $key, $bp->site_options[ $key ] ) )957 $bp->site_options[ $key ] = bp_get_option( $key, $default ); 958 959 if ( !bp_update_option( $key, $bp->site_options[ $key ] ) ) 889 960 $errors = true; 890 961 } … … 908 979 global $bp, $wpdb; 909 980 910 // These options come from the options table in WP single, and sitemeta in MS981 // These options come from the options table 911 982 $site_options = apply_filters( 'bp_core_site_options', array( 912 983 'bp-deactivated-components', … … 936 1007 $meta_keys = "'" . implode( "','", (array)$site_options ) ."'"; 937 1008 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})" ); 1009 $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" ); 1010 1011 // Backward compatibility - moves sitemeta to the blog 1012 if ( empty( $site_meta ) || ( count( $site_meta ) < count( $site_options ) ) ) { 1013 if ( is_multisite() ) { 1014 $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}" ); 1015 } else { 1016 $ms_site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" ); 1017 } 1018 1019 $settings_to_move = array( 1020 'bp-deactivated-components', 1021 'bp-blogs-first-install', 1022 'bp-disable-blog-forum-comments', 1023 'bp-xprofile-base-group-name', 1024 'bp-xprofile-fullname-field-name', 1025 'bp-disable-profile-sync', 1026 'bp-disable-avatar-uploads', 1027 'bp-disable-account-deletion', 1028 'bp-disable-forum-directory', 1029 'bp-disable-blogforum-comments', 1030 'bb-config-location', 1031 'hide-loggedout-adminbar', 1032 ); 1033 1034 foreach( (array)$ms_site_meta as $meta ) { 1035 if ( isset( $meta->name ) && in_array( $meta->name, $settings_to_move ) ) { 1036 bp_update_option( $meta->name, $meta->value ); 1037 1038 if ( empty( $site_meta[$meta->name] ) ) { 1039 $site_meta[$meta->name] = $meta->value; 1040 } 1041 } 1042 } 1043 } 942 1044 943 1045 $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'"; … … 949 1051 if ( !empty( $meta ) ) { 950 1052 foreach( (array)$meta as $meta_item ) { 951 $site_options[$meta_item->name] = $meta_item->value; 1053 if ( isset( $meta_item->name ) ) 1054 $site_options[$meta_item->name] = $meta_item->value; 952 1055 } 953 1056 } -
trunk/bp-core/bp-core-loader.php
r4556 r4559 22 22 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' ); 23 23 24 // Move active components from sitemeta, if necessary 25 // Provides backpat with earlier versions of BP 26 if ( is_multisite() && $active_components = get_site_option( 'bp-active-components' ) ) 27 bp_update_option( 'bp-active-components', $active_components ); 28 24 29 /** "And now for something completely different" ******************************/ 25 30 … … 67 72 68 73 // Get a list of activated components 69 if ( $active_components = get_site_option( 'bp-active-components' ) ) {74 if ( $active_components = bp_get_option( 'bp-active-components' ) ) { 70 75 $bp->active_components = apply_filters( 'bp_active_components', $active_components ); 71 76 $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 ) ) ) ); 72 77 73 78 // Pre 1.3 Backwards compatibility 74 } elseif ( $deactivated_components = get_site_option( 'bp-deactivated-components' ) ) {79 } elseif ( $deactivated_components = bp_get_option( 'bp-deactivated-components' ) ) { 75 80 // Trim off namespace and filename 76 81 foreach ( (array) $deactivated_components as $component => $value ) -
trunk/bp-core/bp-core-template.php
r4554 r4559 442 442 } 443 443 444 function bp_get_option( $option_name ) {445 global $bp;446 447 if ( !empty( $bp->site_options[$option_name] ) )448 $retval = $bp->site_options[$option_name];449 else450 $retval = false;451 452 return apply_filters( 'bp_get_option', $retval );453 }454 455 444 /** 456 445 * Allow templates to pass parameters directly into the template loops via AJAX -
trunk/bp-core/bp-core-wpabstraction.php
r4456 r4559 17 17 18 18 $wpdb->base_prefix = $wpdb->prefix; 19 $wpdb->blogid = 1;19 $wpdb->blogid = BP_ROOT_BLOG; 20 20 21 21 if ( !function_exists( 'get_blog_option' ) ) { 22 22 function get_blog_option( $blog_id, $option_name, $default = false ) { 23 23 return get_option( $option_name, $default ); 24 } 25 } 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 ); 24 30 } 25 31 } -
trunk/bp-forums/bp-forums-admin.php
r4482 r4559 144 144 } 145 145 146 update_site_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );146 bp_update_option( 'bb-config-location', $_REQUEST['bbconfigloc'] ); 147 147 148 148 if ( !file_exists( $_REQUEST['bbconfigloc'] ) ) … … 215 215 } 216 216 217 update_site_option( 'bb-config-location', ABSPATH . 'bb-config.php' );217 bp_update_option( 'bb-config-location', ABSPATH . 'bb-config.php' ); 218 218 return $initial_write; 219 219 } -
trunk/bp-groups/bp-groups-template.php
r4524 r4559 1929 1929 * 1930 1930 * @uses apply_filters() To call 'bp_user_can_create_groups'. 1931 * @uses get_site_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0.1931 * @uses bp_get_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0. 1932 1932 * @uses is_super_admin() To determine if current user if super admin. 1933 1933 * … … 1940 1940 1941 1941 // Get group creation option, default to 0 (allowed) 1942 $restricted = (int) get_site_option( 'bp_restrict_group_creation', 0 );1942 $restricted = (int) bp_get_option( 'bp_restrict_group_creation', 0 ); 1943 1943 1944 1944 // Allow by default -
trunk/bp-members/bp-members-functions.php
r4558 r4559 528 528 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs. 529 529 * @uses wp_delete_user() Deletes a user from the system on singlesite installs. 530 * @uses get_site_option Checks if account deletion is allowed531 530 */ 532 531 function bp_core_delete_account( $user_id = 0 ) { -
trunk/bp-xprofile/bp-xprofile-admin.php
r4364 r4559 50 50 51 51 <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> 53 53 54 54 <form action="" id="profile-field-form" method="post">
Note: See TracChangeset
for help on using the changeset viewer.