Ticket #2518: save_pages_to_blog_meta.patch
| File save_pages_to_blog_meta.patch, 4.2 KB (added by , 16 years ago) |
|---|
-
bp-core/admin/bp-core-upgrade.php
299 299 } 300 300 301 301 function step_pages() { 302 global $current_blog; 303 302 304 if ( !current_user_can( 'activate_plugins' ) ) 303 305 return false; 304 306 305 $existing_pages = get_site_option( 'bp-pages' ); 307 if ( defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) 308 $existing_pages = get_blog_option( $current_blog->blog_id, 'bp-pages' ); 309 else if ( is_multisite() ) 310 $existing_pages = get_blog_option( BP_ROOT_BLOG, 'bp-pages' ); 311 else 312 $existing_pages = get_option( 'bp-pages' ); 313 306 314 $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) ); 307 315 308 316 /* Check for defined slugs */ … … 693 701 } 694 702 695 703 function step_pages_save() { 704 global $current_blog; 705 696 706 if ( isset( $_POST['submit'] ) && isset( $_POST['bp_pages'] ) ) { 697 707 check_admin_referer( 'bpwizard_pages' ); 698 708 699 /* Delete any existing pages */ 700 $existing_pages = get_site_option( 'bp-pages' ); 709 // Make sure that the pages are created on the BP_ROOT_BLOG, no matter which Dashboard the setup is being run on 710 if ( $current_blog->blog_id != BP_ROOT_BLOG && !defined( 'BP_ENABLE_MULTIBLOG' ) ) 711 switch_to_blog( BP_ROOT_BLOG ); 701 712 713 // Delete any existing pages 714 $existing_pages = get_option( 'bp-pages' ); 715 702 716 foreach ( (array)$existing_pages as $page_id ) 703 717 wp_delete_post( $page_id, true ); 704 718 … … 715 729 $bp_pages[$key] = wp_insert_post( array( 'post_title' => ucwords( $value ), 'post_status' => 'publish', 'post_type' => 'page' ) ); 716 730 } 717 731 } 718 update_site_option( 'bp-pages', $bp_pages );719 732 733 update_option( 'bp-pages', $bp_pages ); 734 735 if ( $current_blog->blog_id != BP_ROOT_BLOG ) 736 restore_current_blog(); 737 720 738 return true; 721 739 } 722 740 -
bp-core.php
83 83 84 84 /* Set up the members id and active components entry */ 85 85 $bp->members->id = 'members'; 86 86 87 $bp->members->slug = $bp->pages->members->slug; 87 88 $bp->active_components[$bp->members->slug] = $bp->members->id; 88 89 … … 191 192 } 192 193 add_action( 'bp_setup_globals', 'bp_core_define_slugs' ); 193 194 194 function bp_core_get_page_names() {195 global $wpdb, $current_blog;196 195 196 /** 197 * bp_core_get_page_meta() 198 * 199 * Fetches BP pages from the meta table, depending on setup 200 * 201 * @package BuddyPress Core Core 202 * @global $current_blog 203 */ 204 function bp_core_get_page_meta() { 205 global $current_blog; 206 197 207 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) 198 208 $page_ids = get_blog_option( $current_blog->blog_id, 'bp-pages' ); 209 else if ( BP_ROOT_BLOG != $current_blog->blog_id ) 210 $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' ); 199 211 else 200 $page_ids = get_ blog_option( BP_ROOT_BLOG,'bp-pages' );212 $page_ids = get_option( 'bp-pages' ); 201 213 214 return $page_ids; 215 } 216 217 /** 218 * bp_core_update_page_meta() 219 * 220 * Stores BP pages in the meta table, depending on setup 221 * 222 * @package BuddyPress Core Core 223 * @global $current_blog 224 */ 225 function bp_core_update_page_meta( $page_ids ) { 226 global $current_blog; 227 228 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) 229 update_blog_option( $current_blog->blog_id, 'bp-pages', $page_ids ); 230 else if ( BP_ROOT_BLOG != $current_blog->blog_id ) 231 update_blog_option( BP_ROOT_BLOG, 'bp-pages', $page_ids ); 232 else 233 update_option( 'bp-pages', $page_ids ); 234 } 235 236 237 function bp_core_get_page_names() { 238 global $wpdb, $current_blog; 239 240 $page_ids = bp_core_get_page_meta(); 241 202 242 if ( empty( $page_ids ) ) 203 243 return false; 204 244 … … 2046 2086 foreach ( (array)$bp->add_root as $slug ) 2047 2087 $new_page_ids[$slug] = wp_insert_post( array( 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) ); 2048 2088 2049 $page_ids = get_site_option( 'bp-pages' ); 2089 $page_ids = bp_core_get_page_meta(); 2090 2050 2091 $page_ids = (array) $page_ids; 2051 2092 $page_ids = array_merge( (array) $new_page_ids, (array) $page_ids ); 2052 update_site_option( 'bp-pages', $page_ids ); 2093 2094 bp_core_update_page_meta( $page_ids ); 2053 2095 } 2054 2096 2055 2097 function bp_core_is_root_component( $component_name ) {