Ticket #3261: 3261.patch
| File 3261.patch, 37.0 KB (added by , 15 years ago) |
|---|
-
bp-blogs/bp-blogs-template.php
function bp_total_blog_count_for_user( $user_id = 0 ) { 362 362 function bp_blog_signup_enabled() { 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" 371 368 -
bp-core/admin/bp-core-admin.php
function bp_core_admin_settings() { 58 58 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 } ?> 64 64 … … function bp_core_admin_settings() { 86 86 <tr> 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> 93 93 … … function bp_core_admin_settings() { 96 96 <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> 103 103 104 104 <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> 111 111 112 112 <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> 119 119 … … function bp_core_admin_settings() { 122 122 <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> 129 129 … … function bp_core_admin_settings() { 134 134 <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> 141 141 … … function bp_core_admin_settings() { 146 146 <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> 153 153 … … function bp_core_admin_component_setup_handler() { 183 183 // Settings form submitted, now save the settings. First, set active components 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 189 189 // Then, update the directory pages … … function bp_core_admin_component_setup() { 262 262 */ 263 263 function bp_core_admin_component_options() { 264 264 global $bp_wizard; 265 266 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 265 267 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' ) ); 267 269 268 270 // An array of strings looped over to create component setup markup 269 271 $optional_components = array( -
bp-core/admin/bp-core-schema.php
function bp_core_install_extended_profiles() { 204 204 $charset_collate = bp_core_set_charset(); 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 ( 211 211 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, … … function bp_core_install_extended_profiles() { 262 262 $insert_sql = array(); 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 ); 271 271 } -
bp-core/admin/bp-core-update.php
class BP_Core_Setup_Wizard { 252 252 <?php 253 253 } 254 254 255 function step_ms_update() { 255 function step_ms_update() { 256 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 257 256 258 if ( !current_user_can( 'activate_plugins' ) ) 257 259 return false; 258 260 259 $active_components = get_site_option( 'bp-active-components' );261 $active_components = bp_get_option( 'bp-active-components' ); 260 262 261 263 if ( defined( 'BP_BLOGS_SLUG' ) ) 262 264 $blogs_slug = constant( 'BP_BLOGS_SLUG' ); … … class BP_Core_Setup_Wizard { 264 266 $blogs_slug = 'blogs'; 265 267 266 268 // 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' ); 270 270 271 271 if ( !empty( $existing_pages['blogs'] ) ) 272 272 $existing_blog_page = '&selected=' . $existing_pages['blogs']; … … class BP_Core_Setup_Wizard { 362 362 return false; 363 363 364 364 $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 = ''; 365 377 366 378 // 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' ) ); 368 380 369 381 // Check for defined slugs 370 382 $members_slug = !empty( $bp->members->slug ) ? $bp->members->slug : __( 'members', 'buddypress' ); … … class BP_Core_Setup_Wizard { 758 770 switch_to_blog( BP_ROOT_BLOG ); 759 771 760 772 // 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' ); 764 774 765 775 $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 766 776 $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages ); 767 777 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 ); 771 779 772 780 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) 773 781 restore_current_blog(); … … class BP_Core_Setup_Wizard { 775 783 bp_core_install( $active_components ); 776 784 } 777 785 778 update_site_option( 'bp-active-components', $active_components );786 bp_update_option( 'bp-active-components', $active_components ); 779 787 780 788 return true; 781 789 } … … class BP_Core_Setup_Wizard { 793 801 // Settings form submitted, now save the settings. 794 802 foreach ( (array)$_POST['bp_components'] as $key => $value ) 795 803 $active_components[$key] = 1; 804 805 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 796 806 797 update_site_option( 'bp-active-components', $active_components );807 bp_update_option( 'bp-active-components', $active_components ); 798 808 799 809 wp_cache_flush(); 800 810 bp_core_install(); … … class BP_Core_Setup_Wizard { 822 832 wp_delete_post( $page_id, true ); 823 833 824 834 $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 );827 835 828 update_site_option( 'bp-pages', $bp_pages );836 bp_update_option( 'bp-pages', $blog_pages ); 829 837 830 838 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) 831 839 restore_current_blog(); … … class BP_Core_Setup_Wizard { 994 1002 check_admin_referer( 'bpwizard_finish' ); 995 1003 996 1004 // Update the DB version in the database 1005 // Stored in sitemeta. Do not use bp_update_option() 997 1006 update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) ); 998 1007 delete_site_option( 'bp-core-db-version' ); 999 1008 1000 1009 // Delete the setup cookie 1001 1010 @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); 1002 1011 1003 // Load BP , so that the redirect is successful1012 // Load BP and hook the admin menu, so that the redirect is successful 1004 1013 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' ); 1014 bp_core_add_admin_menu(); 1005 1015 1006 1016 // Redirect to the BuddyPress dashboard 1007 1017 $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 ) { 1061 1071 global $wpdb; 1062 1072 1063 1073 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' ) ); 1065 1075 1066 1076 require_once( dirname( __FILE__ ) . '/bp-core-schema.php' ); 1067 1077 … … function bp_update_db_stuff() { 1117 1127 // On first installation - record all existing blogs in the system. 1118 1128 if ( !(int)$bp->site_options['bp-blogs-first-install'] && is_multisite() ) { 1119 1129 bp_blogs_record_existing_blogs(); 1120 add_site_option( 'bp-blogs-first-install', 1 );1130 update_site_option( 'bp-blogs-first-install', 1 ); 1121 1131 } 1122 1132 1123 1133 if ( is_multisite() ) … … function bp_core_update_add_admin_menu_styles() { 1234 1244 add_action( 'admin_head', 'bp_core_update_add_admin_menu_styles' ); 1235 1245 1236 1246 /** 1237 * Fetches BP pages from the meta table , depending on setup1247 * Fetches BP pages from the meta table 1238 1248 * 1239 1249 * @package BuddyPress Core 1240 1250 * @since 1.3 1241 1251 * 1242 1252 * @return array $page_ids 1243 1253 */ 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; 1254 function 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(); 1252 1259 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 ); 1254 1261 } 1255 1262 1256 1263 function bp_core_update_do_network_admin() { -
bp-core/bp-core-buddybar.php
function bp_core_admin_bar() { 321 321 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR ) 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 327 327 $bp->doing_admin_bar = true; … … function bp_core_load_admin_bar() { 486 486 // Keep the WP admin bar from loading 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 492 492 // Admin bar styles -
bp-core/bp-core-functions.php
1 1 <?php 2 2 3 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 * @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 */ 71 function 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 /** 4 90 * Allow filtering of database prefix. Intended for use in multinetwork installations. 5 91 * 6 92 * @global object $wpdb WordPress database object … … function bp_core_get_table_prefix() { 22 108 * people running trunk installations. Leave for a version or two, then remove. 23 109 */ 24 110 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; 111 $page_ids = bp_get_option( 'bp-pages' ); 30 112 31 113 // 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; 53 116 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 } 55 124 } 56 125 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 ); 60 127 } 61 128 62 129 /** 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 67 131 * 68 132 * @package BuddyPress Core 69 133 * @since 1.3 … … function bp_core_get_page_meta() { 71 135 * @param array $blog_page_ids The IDs of the WP pages corresponding to BP component directories 72 136 */ 73 137 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 ); 138 bp_update_option( 'bp-pages', $blog_page_ids ); 83 139 } 84 140 85 141 /** … … add_action( 'bp_init', 'bp_core_add_ajax_hook' ); 874 930 * site options. 875 931 * 876 932 * @package BuddyPress Core 933 * @todo Does this need to be here anymore after the introduction of bp_get_option etc? 877 934 */ 878 935 function bp_core_activate_site_options( $keys = array() ) { 879 936 global $bp; … … function bp_core_activate_site_options( $keys = array() ) { 883 940 884 941 foreach ( $keys as $key => $default ) { 885 942 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 ); 887 944 888 if ( ! update_site_option( $key, $bp->site_options[ $key ] ) )945 if ( !bp_update_option( $key, $bp->site_options[ $key ] ) ) 889 946 $errors = true; 890 947 } 891 948 } … … function bp_core_activate_site_options( $keys = array() ) { 907 964 function bp_core_get_site_options() { 908 965 global $bp, $wpdb; 909 966 910 // These options come from the options table in WP single, and sitemeta in MS967 // These options come from the options table 911 968 $site_options = apply_filters( 'bp_core_site_options', array( 912 969 'bp-deactivated-components', 913 970 'bp-blogs-first-install', … … function bp_core_get_site_options() { 935 992 936 993 $meta_keys = "'" . implode( "','", (array)$site_options ) ."'"; 937 994 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 } 942 1030 943 1031 $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'"; 944 1032 $root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options'; … … function bp_core_get_site_options() { 948 1036 foreach( array( $site_meta, $root_blog_meta ) as $meta ) { 949 1037 if ( !empty( $meta ) ) { 950 1038 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; 952 1041 } 953 1042 } 954 1043 } -
bp-core/bp-core-loader.php
require_once( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php' ); 21 21 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) ) 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 26 31 class BP_Core extends BP_Component { … … class BP_Core extends BP_Component { 60 65 $bp->required_components = apply_filters( 'bp_required_components', array( 'members', ) ); 61 66 62 67 // 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' ) ) { 64 69 $bp->active_components = apply_filters( 'bp_active_components', $active_components ); 65 70 $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 ) ) ) ); 66 71 67 72 // 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' ) ) { 69 74 // Trim off namespace and filename 70 75 foreach ( $deactivated_components as $component => $value ) 71 76 $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) ); -
bp-core/bp-core-template.php
function bp_registration_needs_activation() { 538 538 return apply_filters( 'bp_registration_needs_activation', true ); 539 539 } 540 540 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 else547 $retval = false;548 549 return apply_filters( 'bp_get_option', $retval );550 }551 552 541 /** 553 542 * Allow templates to pass parameters directly into the template loops via AJAX 554 543 * -
bp-core/bp-core-wpabstraction.php
if ( !is_multisite() ) { 16 16 global $wpdb; 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 24 } 25 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 ); 30 } 31 } 26 32 27 33 if ( !function_exists( 'switch_to_blog' ) ) { 28 34 function switch_to_blog() { -
bp-forums/bp-forums-admin.php
function bp_forums_configure_existing_install() { 143 143 $_REQUEST['bbconfigloc'] .= 'bb-config.php'; 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'] ) ) 149 149 return false; … … function bp_forums_bbpress_install() { 214 214 $initial_write = $file; 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 } 220 220 -
bp-groups/bp-groups-template.php
function bp_group_member_admin_pagination() { 1740 1740 * @since BuddyPress 1.3 1741 1741 * 1742 1742 * @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. 1744 1744 * @uses is_super_admin() To determine if current user if super admin. 1745 1745 * 1746 1746 * @return bool True if user can create groups. False otherwise. … … function bp_user_can_create_groups() { 1751 1751 return true; 1752 1752 1753 1753 // 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 ); 1755 1755 1756 1756 // Allow by default 1757 1757 $can_create = true; -
bp-members/bp-members-functions.php
function bp_core_get_all_posts_for_user( $user_id = 0 ) { 535 535 * @uses is_super_admin() Checks to see if the user is a site administrator. 536 536 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs. 537 537 * @uses wp_delete_user() Deletes a user from the system on singlesite installs. 538 * @uses get_site_option Checks if account deletion is allowed539 538 */ 540 539 function bp_core_delete_account( $user_id = 0 ) { 541 540 global $bp, $wp_version; -
bp-xprofile/bp-xprofile-admin.php
function xprofile_admin( $message = '', $type = 'error' ) { 49 49 </h2> 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"> 55 55
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)