981 | | // These options come from the options table |
982 | | $site_options = apply_filters( 'bp_core_site_options', array( |
983 | | 'bp-deactivated-components', |
984 | | 'bp-blogs-first-install', |
985 | | 'bp-disable-blog-forum-comments', |
986 | | 'bp-xprofile-base-group-name', |
987 | | 'bp-xprofile-fullname-field-name', |
988 | | 'bp-disable-profile-sync', |
989 | | 'bp-disable-avatar-uploads', |
990 | | 'bp-disable-account-deletion', |
991 | | 'bp-disable-forum-directory', |
992 | | 'bp-disable-blogforum-comments', |
993 | | 'bb-config-location', |
994 | | 'hide-loggedout-adminbar', |
| 982 | // These options come from the root blog options table |
| 983 | $root_blog_options = apply_filters( 'bp_core_site_options', array( |
| 984 | |
| 985 | // BuddyPress core settings |
| 986 | 'bp-deactivated-components' => serialize( array( ) ), |
| 987 | 'bp-blogs-first-install' => '0', |
| 988 | 'bp-disable-blog-forum-comments' => '0', |
| 989 | 'bp-xprofile-base-group-name' => 'Base', |
| 990 | 'bp-xprofile-fullname-field-name' => 'Name', |
| 991 | 'bp-disable-profile-sync' => '0', |
| 992 | 'bp-disable-avatar-uploads' => '0', |
| 993 | 'bp-disable-account-deletion' => '0', |
| 994 | 'bp-disable-forum-directory' => '0', |
| 995 | 'bp-disable-blogforum-comments' => '0', |
| 996 | 'bb-config-location' => ABSPATH, |
| 997 | 'hide-loggedout-adminbar' => '0', |
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})" ); |
| 1016 | // Loop through options |
| 1017 | foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) { |
| 1018 | |
| 1019 | // Clear out the value from the last time around |
| 1020 | unset( $old_meta_value ); |
| 1021 | |
| 1022 | // Get old site option |
| 1023 | if ( is_multisite() ) |
| 1024 | $old_meta_value = get_site_option( $old_meta_key ); |
| 1025 | |
| 1026 | // No site option so look in root blog |
| 1027 | if ( empty( $old_meta_value ) ) |
| 1028 | $old_meta_value = bp_get_option( $old_meta_key, $old_meta_default ); |
| 1029 | |
| 1030 | // Update the root blog option |
| 1031 | bp_update_option( $old_meta_key, $old_meta_value ); |
| 1032 | |
| 1033 | // Update the global array |
| 1034 | $root_blog_options_meta[$old_meta_key] = $old_meta_value; |
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 | | } |
| 1037 | // We're all matched up |
| 1038 | } else { |
1045 | | $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'"; |
1046 | | $root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options'; |
1047 | | $root_blog_meta = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) ); |
1048 | | $site_options = array(); |
| 1040 | // Loop through our results and make them usable |
| 1041 | foreach ( $root_blog_options_meta as $root_blog_option ) |
| 1042 | $root_blog_options[$root_blog_option->name] = $root_blog_option->value; |
1050 | | foreach( array( $site_meta, $root_blog_meta ) as $meta ) { |
1051 | | if ( !empty( $meta ) ) { |
1052 | | foreach( (array)$meta as $meta_item ) { |
1053 | | if ( isset( $meta_item->name ) ) |
1054 | | $site_options[$meta_item->name] = $meta_item->value; |
1055 | | } |
1056 | | } |
| 1044 | // Copy the options no the return val |
| 1045 | $root_blog_options_meta = $root_blog_options; |
| 1046 | |
| 1047 | // Clean up our temporary copy |
| 1048 | unset( $root_blog_options ); |