Ticket #3144: 3144.patch
File 3144.patch, 3.8 KB (added by , 14 years ago) |
---|
-
bp-core/bp-core-functions.php
function bp_core_get_table_prefix() { 18 18 * @package BuddyPress Core 19 19 */ 20 20 function bp_core_get_page_meta() { 21 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) 22 $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' ); 23 else 24 $page_ids = get_option( 'bp-pages' ); 21 $page_ids = get_site_option( 'bp-pages' ); 22 23 $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false; 24 25 // Upgrading from an earlier version of BP pre-1.3 26 if ( empty( $page_ids ) || isset( $page_ids['members'] ) ) { 27 if ( !$is_enable_multiblog ) { 28 if ( empty( $page_ids ) ) 29 $old_page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' ); 30 31 $page_ids = array( 32 BP_ROOT_BLOG => $old_page_ids 33 ); 34 } else { 35 if ( empty( $page_ids ) ) 36 $old_page_ids = get_option( 'bp-pages' ); 25 37 26 return $page_ids; 38 $page_ids = array( 39 get_current_blog_id() => $old_page_ids 40 ); 41 } 42 43 update_site_option( 'bp-pages', $page_ids ); 44 } 45 46 $key = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG; 47 48 $blog_page_ids = $page_ids[$key]; 49 50 return $blog_page_ids; 27 51 } 28 52 29 53 /** 30 54 * Stores BP pages in the meta table, depending on setup 31 55 * 32 * bp-pages data is stored in the options table of the root blog, except when BP_ENABLE_MULTIBLOG33 * is turned on.56 * bp-pages data is stored in site_options (falls back to options on non-MS), in an array keyed by 57 * blog_id. This allows you to change your BP_ROOT_BLOG and go through the setup process again. 34 58 * 35 59 * @package BuddyPress Core 36 60 * @since 1.3 37 61 * 38 * @param array $ page_ids The IDs of the WP pages corresponding to BP component directories62 * @param array $blog_page_ids The IDs of the WP pages corresponding to BP component directories 39 63 */ 40 function bp_core_update_page_meta( $page_ids ) { 41 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) 42 update_blog_option( BP_ROOT_BLOG, 'bp-pages', $page_ids ); 43 else 44 update_option( 'bp-pages', $page_ids ); 64 function bp_core_update_page_meta( $blog_page_ids ) { 65 if ( !$page_ids = get_site_option( 'bp-pages' ) ) 66 $page_ids = array(); 67 68 // Generally, we key by the BP_ROOT_BLOG. Exception: when BP_ENABLE_MULTIBLOG is turned on 69 $key = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 70 71 $page_ids[$key] = $blog_page_ids; 72 73 update_site_option( 'bp-pages', $page_ids ); 45 74 } 46 75 47 76 /** … … function bp_core_get_page_names() { 63 92 64 93 $posts_table_name = is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'posts' : $wpdb->posts; 65 94 $page_ids_sql = implode( ',', (array)$page_ids ); 66 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status = 'publish' " ) );95 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent, post_title FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status = 'publish' " ) ); 67 96 68 97 foreach ( (array)$page_ids as $key => $page_id ) { 69 98 foreach ( (array)$page_names as $page_name ) { 70 99 if ( $page_name->ID == $page_id ) { 71 $pages->{$key}->name = $page_name->post_name; 72 $pages->{$key}->id = $page_name->ID; 73 $slug[] = $page_name->post_name; 100 $pages->{$key}->name = $page_name->post_name; 101 $pages->{$key}->id = $page_name->ID; 102 $pages->{$key}->title = $page_name->post_title; 103 $slug[] = $page_name->post_name; 74 104 75 105 // Get the slug 76 106 while ( $page_name->post_parent != 0 ) {