Changeset 4855
- Timestamp:
- 07/25/2011 09:03:23 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r4829 r4855 969 969 */ 970 970 function bp_core_get_root_options() { 971 global $wpdb; 972 973 // These options come from the root blog options table 974 $root_blog_options = apply_filters( 'bp_core_site_options', array( 975 976 // BuddyPress core settings 977 'bp-deactivated-components' => serialize( array( ) ), 978 'bp-blogs-first-install' => '0', 979 'bp-disable-blog-forum-comments' => '0', 980 'bp-xprofile-base-group-name' => 'Base', 981 'bp-xprofile-fullname-field-name' => 'Name', 982 'bp-disable-profile-sync' => '0', 983 'bp-disable-avatar-uploads' => '0', 984 'bp-disable-account-deletion' => '0', 985 'bp-disable-blogforum-comments' => '0', 986 'bb-config-location' => ABSPATH, 987 'hide-loggedout-adminbar' => '0', 988 989 // Useful WordPress settings 990 'tags_blog_id' => '0', 991 'registration' => '0', 992 'fileupload_maxk' => '1500', 993 'avatar_default' => 'mysteryman' 994 ) ); 995 $root_blog_option_keys = array_keys( $root_blog_options ); 996 $blog_options_keys = implode( "', '", (array) $root_blog_option_keys ); 997 $blog_options_query = sprintf( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ('%s')", $blog_options_keys ); 998 $root_blog_options_meta = $wpdb->get_results( $blog_options_query ); 999 1000 // Missing some options, so do some one-time fixing 1001 if ( empty( $root_blog_options_meta ) || ( count( $root_blog_options_meta ) < count( $root_blog_option_keys ) ) ) { 1002 1003 // Unset the query - We'll be resetting it soon 1004 unset( $root_blog_options_meta ); 1005 1006 // Loop through options 1007 foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) { 1008 1009 // Clear out the value from the last time around 1010 unset( $old_meta_value ); 1011 1012 // Get old site option 1013 if ( is_multisite() ) 1014 $old_meta_value = get_site_option( $old_meta_key ); 1015 1016 // No site option so look in root blog 1017 if ( empty( $old_meta_value ) ) 1018 $old_meta_value = bp_get_option( $old_meta_key, $old_meta_default ); 1019 1020 // Update the root blog option 1021 bp_update_option( $old_meta_key, $old_meta_value ); 1022 1023 // Update the global array 1024 $root_blog_options_meta[$old_meta_key] = $old_meta_value; 1025 } 1026 1027 // We're all matched up 1028 } else { 1029 1030 // Loop through our results and make them usable 1031 foreach ( $root_blog_options_meta as $root_blog_option ) 1032 $root_blog_options[$root_blog_option->name] = $root_blog_option->value; 1033 1034 // Copy the options no the return val 1035 $root_blog_options_meta = $root_blog_options; 1036 1037 // Clean up our temporary copy 1038 unset( $root_blog_options ); 1039 } 1040 1041 return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta ); 971 global $wpdb; 972 973 // These options come from the root blog options table 974 $root_blog_options = apply_filters( 'bp_core_site_options', array( 975 976 // BuddyPress core settings 977 'bp-deactivated-components' => serialize( array( ) ), 978 'bp-blogs-first-install' => '0', 979 'bp-disable-blog-forum-comments' => '0', 980 'bp-xprofile-base-group-name' => 'Base', 981 'bp-xprofile-fullname-field-name' => 'Name', 982 'bp-disable-profile-sync' => '0', 983 'bp-disable-avatar-uploads' => '0', 984 'bp-disable-account-deletion' => '0', 985 'bp-disable-blogforum-comments' => '0', 986 'bb-config-location' => ABSPATH, 987 'hide-loggedout-adminbar' => '0', 988 989 // Useful WordPress settings 990 'registration' => '0', 991 'avatar_default' => 'mysteryman' 992 ) ); 993 994 $root_blog_option_keys = array_keys( $root_blog_options ); 995 $blog_options_keys = implode( "', '", (array) $root_blog_option_keys ); 996 $blog_options_query = sprintf( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ('%s')", $blog_options_keys ); 997 $root_blog_options_meta = $wpdb->get_results( $blog_options_query ); 998 999 // On Multisite installations, some options must always be fetched from sitemeta 1000 if ( is_multisite() ) { 1001 $network_options = apply_filters( 'bp_core_network_options', array( 1002 'tags_blog_id' => '0', 1003 'registration' => '0', 1004 'fileupload_maxk' => '1500' 1005 ) ); 1006 1007 $network_option_keys = array_keys( $network_options ); 1008 $sitemeta_options_keys = implode( "','", (array) $network_option_keys ); 1009 $sitemeta_options_query = sprintf( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ('%s')", $sitemeta_options_keys ); 1010 $network_options_meta = $wpdb->get_results( $sitemeta_options_query ); 1011 1012 // Sitemeta comes second in the merge, so that network 'registration' value wins 1013 $root_blog_options_meta = array_merge( $root_blog_options_meta, $network_options_meta ); 1014 } 1015 1016 // Missing some options, so do some one-time fixing 1017 if ( empty( $root_blog_options_meta ) || ( count( $root_blog_options_meta ) < count( $root_blog_option_keys ) ) ) { 1018 1019 // Unset the query - We'll be resetting it soon 1020 unset( $root_blog_options_meta ); 1021 1022 // Loop through options 1023 foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) { 1024 // Clear out the value from the last time around 1025 unset( $old_meta_value ); 1026 1027 // Get old site option 1028 if ( is_multisite() ) 1029 $old_meta_value = get_site_option( $old_meta_key ); 1030 1031 // No site option so look in root blog 1032 if ( empty( $old_meta_value ) ) 1033 $old_meta_value = bp_get_option( $old_meta_key, $old_meta_default ); 1034 1035 // Update the root blog option 1036 bp_update_option( $old_meta_key, $old_meta_value ); 1037 1038 // Update the global array 1039 $root_blog_options_meta[$old_meta_key] = $old_meta_value; 1040 } 1041 1042 // We're all matched up 1043 } else { 1044 // Loop through our results and make them usable 1045 foreach ( $root_blog_options_meta as $root_blog_option ) 1046 $root_blog_options[$root_blog_option->name] = $root_blog_option->value; 1047 1048 // Copy the options no the return val 1049 $root_blog_options_meta = $root_blog_options; 1050 1051 // Clean up our temporary copy 1052 unset( $root_blog_options ); 1053 } 1054 1055 return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta ); 1042 1056 } 1043 1057
Note: See TracChangeset
for help on using the changeset viewer.