Changeset 3736
- Timestamp:
- 01/18/2011 10:46:09 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs.php
r3728 r3736 14 14 if ( !defined( 'BP_BLOGS_SLUG' ) && isset( $bp->pages->blogs->slug ) ) 15 15 define ( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->blogs->slug ) ); 16 else if ( !defined( 'BP_BLOGS_SLUG' ) )16 else if ( !defined( 'BP_BLOGS_SLUG' ) ) 17 17 define ( 'BP_BLOGS_SLUG', 'blogs' ); 18 18 19 19 // For internal identification 20 20 $bp->blogs->id = 'blogs'; 21 $bp->blogs->name = $bp->pages->blogs->name;21 $bp->blogs->name = !empty( $bp->pages->blogs->name ) ? $bp->pages->blogs->name : 'blogs'; 22 22 23 23 // Slugs 24 24 $bp->blogs->slug = BP_BLOGS_SLUG; 25 $bp->blogs->root_slug = $bp->pages->blogs->slug;25 $bp->blogs->root_slug = !empty( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG; 26 26 27 27 // Tables … … 558 558 function bp_blogs_remove_post( $post_id, $blog_id = false, $user_id = false ) { 559 559 global $current_blog, $bp; 560 561 if ( empty( $current_blog->blog_id ) ) 562 return false; 560 563 561 564 $post_id = (int)$post_id; -
trunk/bp-core.php
r3734 r3736 44 44 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' ); 45 45 46 // Register BuddyPress themes contained within the bp-theme folder47 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );48 49 46 /** "And now for something completely different" ******************************/ 50 47 … … 208 205 * These can be overridden manually by defining these slugs in wp-config.php. 209 206 * 207 * The fallback values are only used during initial BP page creation, when no slugs have been 208 * explicitly defined. 209 * 210 210 * @package BuddyPress Core Core 211 211 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 216 216 if ( !defined( 'BP_MEMBERS_SLUG' ) ) 217 217 define( 'BP_MEMBERS_SLUG', $bp->pages->members->slug ); 218 218 219 219 if ( !defined( 'BP_REGISTER_SLUG' ) ) 220 220 define( 'BP_REGISTER_SLUG', $bp->pages->register->slug ); 221 221 222 222 if ( !defined( 'BP_ACTIVATION_SLUG' ) ) 223 223 define( 'BP_ACTIVATION_SLUG', $bp->pages->activate->slug ); 224 224 225 } 225 226 add_action( 'bp_setup_globals', 'bp_core_define_slugs' ); … … 258 259 $page_ids = bp_core_get_page_meta(); 259 260 260 if ( empty( $page_ids ) ) 261 return false; 261 $pages = new stdClass; 262 263 // When upgrading to BP 1.3+ from a version of BP that does not use WP pages, $bp->pages 264 // must be populated with dummy info to avoid crashing the site while the db is upgraded 265 if ( empty( $page_ids ) ) { 266 $dummy_components = array( 267 'members', 268 'groups', 269 'activity', 270 'forums', 271 'activate', 272 'register', 273 'blogs' 274 ); 275 276 foreach ( $dummy_components as $dc ) { 277 $pages->{$dc}->name = $dc; 278 $pages->{$dc}->slug = $dc; 279 $pages->{$dc}->id = $dc; 280 } 281 282 return $pages; 283 } 262 284 263 285 $posts_table_name = is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'posts' : $wpdb->posts; … … 266 288 267 289 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) " ) ); 268 $pages = new stdClass;269 290 270 291 foreach ( (array)$page_ids as $key => $page_id ) { … … 348 369 if ( !is_super_admin() ) 349 370 return false; 371 372 // Don't add this version of the admin menu if a BP upgrade is in progress 373 // See bp_core_update_add_admin_menu() 374 if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE ) 375 return false; 350 376 351 377 // Add the administration tab under the "Site Admin" tab for site administrators -
trunk/bp-core/admin/bp-core-update.php
r3728 r3736 1 1 <?php 2 3 if ( !defined( 'BP_ROOT_BLOG' ) )4 define( 'BP_ROOT_BLOG', 1 );5 6 require_once( dirname( dirname( __FILE__ ) ) . '/bp-core-wpabstraction.php' );7 8 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );9 10 // Install site options on activation11 bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0, 'bp-disable-forum-directory' => 0, 'bp-disable-profile-sync' => 0 ) );12 13 /**14 * When switching from single to multisite we need to copy blog options to15 * site options.16 *17 * @package BuddyPress Core18 */19 function bp_core_activate_site_options( $keys = array() ) {20 global $bp;21 22 $bp->site_options = bp_core_get_site_options();23 24 if ( !empty( $keys ) && is_array( $keys ) ) {25 $errors = false;26 27 foreach ( $keys as $key => $default ) {28 if ( empty( $bp->site_options[ $key ] ) ) {29 $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );30 31 if ( !update_site_option( $key, $bp->site_options[ $key ] ) )32 $errors = true;33 }34 }35 36 if ( empty( $errors ) )37 return true;38 }39 40 return false;41 }42 2 43 3 class BP_Core_Setup_Wizard { … … 115 75 $steps[] = __( 'Database Update', 'buddypress' ); 116 76 117 if ( $this->current_version < 1225 )77 if ( $this->current_version < 1225 || ( function_exists( 'bp_core_get_page_meta' ) && !bp_core_get_page_meta() ) ) 118 78 $steps[] = __( 'Pages', 'buddypress' ); 119 79 … … 152 112 break; 153 113 } 154 114 155 115 if ( !$result && $this->current_step ) 156 116 $this->current_step--; … … 461 421 462 422 // Check for defined slugs 463 if ( defined( 'BP_MEMBERS_SLUG' ) )423 if ( defined( 'BP_MEMBERS_SLUG' ) && BP_MEMBERS_SLUG ) 464 424 $members_slug = constant( 'BP_MEMBERS_SLUG' ); 465 425 else 466 426 $members_slug = __( 'members', 'buddypress' ); 467 427 468 if ( defined( 'BP_GROUPS_SLUG' ) )428 if ( defined( 'BP_GROUPS_SLUG' ) && BP_GROUPS_SLUG ) 469 429 $groups_slug = constant( 'BP_GROUPS_SLUG' ); 470 430 else 471 431 $groups_slug = __( 'groups', 'buddypress' ); 472 432 473 if ( defined( 'BP_ACTIVITY_SLUG' ) )433 if ( defined( 'BP_ACTIVITY_SLUG' ) && BP_ACTIVITY_SLUG ) 474 434 $activity_slug = constant( 'BP_ACTIVITY_SLUG' ); 475 435 else 476 436 $activity_slug = __( 'activity', 'buddypress' ); 477 437 478 if ( defined( 'BP_FORUMS_SLUG' ) )438 if ( defined( 'BP_FORUMS_SLUG' ) && BP_FORUMS_SLUG ) 479 439 $forums_slug = constant( 'BP_FORUMS_SLUG' ); 480 440 else 481 441 $forums_slug = __( 'forums', 'buddypress' ); 482 442 483 if ( defined( 'BP_BLOGS_SLUG' ) )443 if ( defined( 'BP_BLOGS_SLUG' ) && BP_BLOGS_SLUG ) 484 444 $blogs_slug = constant( 'BP_BLOGS_SLUG' ); 485 445 else 486 446 $blogs_slug = __( 'blogs', 'buddypress' ); 487 447 488 if ( defined( 'BP_REGISTER_SLUG' ) )448 if ( defined( 'BP_REGISTER_SLUG' ) && BP_REGISTER_SLUG ) 489 449 $register_slug = constant( 'BP_REGISTER_SLUG' ); 490 450 else 491 451 $register_slug = __( 'register', 'buddypress' ); 492 452 493 if ( defined( 'BP_ACTIVATION_SLUG' ) )453 if ( defined( 'BP_ACTIVATION_SLUG' ) && BP_ACTIVATION_SLUG ) 494 454 $activation_slug = constant( 'BP_ACTIVATION_SLUG' ); 495 455 else … … 787 747 } 788 748 789 function step_finish() { 749 function step_finish() { 750 // Update the DB version in the database 751 update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) ); 752 delete_site_option( 'bp-core-db-version' ); 753 790 754 if ( !current_user_can( 'activate_plugins' ) ) 791 755 return false; … … 829 793 if ( $this->current_version < 1225 ) 830 794 $this->update_1_3(); 831 795 832 796 return true; 833 797 } … … 918 882 919 883 // Delete any existing pages 920 $existing_pages = get_option( 'bp-pages' );884 $existing_pages = bp_core_update_get_page_meta( 'bp-pages' ); 921 885 922 886 foreach ( (array)$existing_pages as $page_id ) … … 1061 1025 if ( isset( $_POST['submit'] ) ) { 1062 1026 check_admin_referer( 'bpwizard_finish' ); 1063 1027 1064 1028 // Delete the setup cookie 1065 1029 @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); … … 1122 1086 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_setup_wizard_init', 7 ); 1123 1087 1124 1125 1088 function bp_core_install( $disabled = false ) { 1126 1089 global $wpdb; … … 1199 1162 1200 1163 /** 1201 * bp_core_add_admin_menu_page()1202 *1203 1164 * A better version of add_admin_menu_page() that allows positioning of menus. 1204 1165 * 1205 1166 * @package BuddyPress Core 1206 1167 */ 1207 function bp_core_ add_admin_menu_page( $args = '' ) {1168 function bp_core_update_add_admin_menu_page( $args = '' ) { 1208 1169 global $menu, $admin_page_hooks, $_registered_pages; 1209 1170 … … 1272 1233 * @uses add_submenu_page() WP function to add a submenu item 1273 1234 */ 1274 function bp_core_ add_admin_menu() {1235 function bp_core_update_add_admin_menu() { 1275 1236 global $bp_wizard; 1276 1237 1238 // Only load this version of the menu if this is an upgrade or a new installation 1239 if ( ( !defined( 'BP_IS_UPGRADE' ) || !BP_IS_UPGRADE ) && ( !defined( 'BP_IS_INSTALL' ) || !BP_IS_INSTALL ) ) 1240 return false; 1241 1277 1242 if ( !current_user_can( 'activate_plugins' ) ) 1278 1243 return false; … … 1284 1249 1285 1250 // Add the administration tab under the "Site Admin" tab for site administrators 1286 bp_core_ add_admin_menu_page( array(1251 bp_core_update_add_admin_menu_page( array( 1287 1252 'menu_title' => __( 'BuddyPress', 'buddypress' ), 1288 1253 'page_title' => __( 'BuddyPress', 'buddypress' ), … … 1296 1261 1297 1262 // Add a hook for css/js 1298 add_action( "admin_print_styles-$hook", 'bp_core_ add_admin_menu_styles' );1263 add_action( "admin_print_styles-$hook", 'bp_core_update_add_admin_menu_styles' ); 1299 1264 } 1300 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_ add_admin_menu', 9 );1301 1302 function bp_core_ add_admin_menu_styles() {1265 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_update_add_admin_menu', 9 ); 1266 1267 function bp_core_update_add_admin_menu_styles() { 1303 1268 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) 1304 1269 wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( $path = '/buddypress' ) . '/bp-core/css/admin.dev.css' ) ); … … 1329 1294 <?php 1330 1295 } 1331 add_action( 'admin_head', 'bp_core_add_admin_menu_styles' ); 1296 add_action( 'admin_head', 'bp_core_update_add_admin_menu_styles' ); 1297 1298 /** 1299 * Fetches BP pages from the meta table, depending on setup 1300 * 1301 * @package BuddyPress Core 1302 * @since 1.3 1303 * 1304 * @return array $page_ids 1305 */ 1306 function bp_core_update_get_page_meta() { 1307 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) 1308 $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' ); 1309 else 1310 $page_ids = get_option( 'bp-pages' ); 1311 1312 return $page_ids; 1313 } 1314 1315 /** 1316 * Adds an admin nag about running the BP upgrade/install wizard 1317 * 1318 * @package BuddyPress Core 1319 * @since 1.3 1320 * @global $pagenow The current admin page 1321 */ 1322 function bp_core_update_nag() { 1323 global $pagenow; 1324 1325 if ( !is_super_admin() ) 1326 return; 1327 1328 if ( 'admin.php' == $pagenow && ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) ) 1329 return; 1330 1331 if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE ) 1332 $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">upgrade wizard</a>.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) ); 1333 else if ( defined( 'BP_IS_INSTALL' ) && BP_IS_INSTALL ) 1334 $msg = sprintf( __( 'BuddyPress has been installed! Please run the <a href="%s">upgrade wizard</a>.', 'buddypress' ), admin_url( 'admin.php?page=bp-wizard' ) ); 1335 1336 echo "<div class='update-nag'>$msg</div>"; 1337 } 1338 add_action( 'admin_notices', 'bp_core_update_nag', 5 ); 1339 1332 1340 1333 1341 ?> -
trunk/bp-loader.php
r3728 r3736 11 11 12 12 define( 'BP_VERSION', '1.3-bleeding' ); 13 define( 'BP_DB_VERSION', 1225 );13 define( 'BP_DB_VERSION', 3705 ); 14 14 15 15 // Define on which blog ID BuddyPress should run … … 17 17 define( 'BP_ROOT_BLOG', 1 ); 18 18 19 /*** 20 * Check if this is the first time BuddyPress has been loaded, or the first time 21 * since an update. If so, load the install/update routine only. 22 */ 23 if ( get_site_option( 'bp-db-version' ) < constant( 'BP_DB_VERSION' ) ) { 19 // Register BuddyPress themes contained within the bp-themes folder 20 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' ); 21 22 // Test to see whether this is a new installation or an upgraded version of BuddyPress 23 $bp_db_version = get_site_option( 'bp-db-version' ); 24 if ( ! $bp_db_version ) 25 $bp_db_version = get_site_option( 'bp-core-db-version' ); // BP 1.2 option name 26 27 if ( ! $bp_db_version ) { 28 // This is a new installation. Run the wizard before loading BP core files 29 define( 'BP_IS_INSTALL', true ); 24 30 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 25 26 /***27 * If the install or update routine is completed and everything is up to date28 * continue loading BuddyPress as normal.29 */30 31 } else { 31 32 /*** … … 65 66 if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) 66 67 include( BP_PLUGIN_DIR . '/bp-xprofile.php' ); 68 69 // If this is an upgrade, load the upgrade file 70 if ( $bp_db_version < constant( 'BP_DB_VERSION' ) ) { 71 define( 'BP_IS_UPGRADE', true ); 72 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 73 } 67 74 68 75 add_action( 'plugins_loaded', 'bp_loaded', 20 ); … … 136 143 } 137 144 138 // Activation Function 145 /** 146 * Defines BP's activation routine. 147 * 148 * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some 149 * issues with incompatible legacy themes, and provides a hook for other functions to know that 150 * BP has been activated. 151 * 152 * @package BuddyPress Core 153 */ 139 154 function bp_loader_activate() { 140 155 // Force refresh theme roots. 141 156 delete_site_transient( 'theme_roots' ); 157 158 if ( !function_exists( 'get_blog_option' ) ) 159 require ( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-wpabstraction.php' ); 142 160 143 161 // Switch the user to the new bp-default if they are using the old -
trunk/bp-themes/bp-default/functions.php
r3724 r3736 36 36 if ( ! isset( $content_width ) ) 37 37 $content_width = 591; 38 39 /**40 * Temporary work-around to prevent errors with bp-default being active41 * when BuddyPress is not installed.42 */43 if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) {44 switch_theme( 'twentyten', 'twentyten' );45 wp_redirect( $_SERVER['HTTP_REFERER'] );46 exit;47 }48 38 49 39 if ( !function_exists( 'bp_dtheme_setup' ) ) :
Note: See TracChangeset
for help on using the changeset viewer.