Ticket #2789: 2789.009.patch
File 2789.009.patch, 14.0 KB (added by , 14 years ago) |
---|
-
bp-themes/bp-default/functions.php
40 40 * Temporary work-around to prevent errors with bp-default being active 41 41 * when BuddyPress is not installed. 42 42 */ 43 if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) {43 /*if ( !constant( 'BP_VERSION' ) || !get_site_option( 'bp-db-version' ) ) { 44 44 switch_theme( 'twentyten', 'twentyten' ); 45 45 wp_redirect( $_SERVER['HTTP_REFERER'] ); 46 46 exit; 47 } 47 }*/ 48 48 49 49 if ( !function_exists( 'bp_dtheme_setup' ) ) : 50 50 /** -
bp-core/admin/bp-core-update.php
1 1 <?php 2 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 43 3 class BP_Core_Setup_Wizard { 44 4 var $current_step; 45 5 var $steps; … … 114 74 if ( $this->current_version < $this->new_version ) 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 120 80 $steps[] = __( 'Finish', 'buddypress' ); … … 151 111 $result = $this->step_finish_save(); 152 112 break; 153 113 } 154 114 155 115 if ( !$result && $this->current_step ) 156 116 $this->current_step--; 157 117 … … 460 420 $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) ); 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 496 456 $activation_slug = __( 'activate', 'buddypress' ); … … 786 746 <?php 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; 792 756 … … 828 792 829 793 if ( $this->current_version < 1225 ) 830 794 $this->update_1_3(); 831 795 832 796 return true; 833 797 } 834 798 … … 917 881 switch_to_blog( BP_ROOT_BLOG ); 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 ) 923 887 wp_delete_post( $page_id, true ); … … 1060 1024 function step_finish_save() { 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 ); 1066 1030 … … 1121 1085 } 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; 1127 1090 … … 1198 1161 } 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 1210 1171 $defaults = array( … … 1271 1232 * @global $wpdb WordPress DB access object. 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; 1279 1244 … … 1283 1248 $status = __( 'Update', 'buddypress' ); 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' ), 1289 1254 'capability' => 'manage_options', … … 1295 1260 $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) ); 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 );1265 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_update_add_admin_menu', 9 ); 1301 1266 1302 function bp_core_ add_admin_menu_styles() {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' ) ); 1305 1270 else … … 1330 1295 } 1331 1296 add_action( 'admin_head', 'bp_core_add_admin_menu_styles' ); 1332 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 1340 1333 1341 ?> -
bp-loader.php
10 10 */ 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 16 16 if ( !defined( 'BP_ROOT_BLOG' ) ) 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 /*** 32 33 * This file will load in each BuddyPress component based on which … … 64 65 // Extended Profiles 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 ); 69 76 } … … 135 142 return apply_filters( 'bp_core_get_site_options', $site_options ); 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' ); 142 157 158 if ( !function_exists( 'get_blog_option' ) ) 159 require ( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-wpabstraction.php' ); 160 143 161 // Switch the user to the new bp-default if they are using the old 144 162 // bp-default on activation. 145 163 if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) ) -
bp-blogs.php
13 13 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 -
bp-core.php
43 43 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) ) 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 51 48 /** … … 207 204 * Define the slugs used for BuddyPress pages, based on the slugs of the WP pages used. 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() 212 212 */ … … 215 215 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' ); 226 227 … … 347 348 function bp_core_add_admin_menu() { 348 349 if ( !is_super_admin() ) 349 350 return false; 351 352 // Don't add this version of the admin menu if a BP upgrade is in progress 353 // See bp_core_update_add_admin_menu() 354 if ( defined( 'BP_IS_UPGRADE' ) && BP_IS_UPGRADE ) 355 return false; 350 356 351 357 // Add the administration tab under the "Site Admin" tab for site administrators 352 358 $hook = bp_core_add_admin_menu_page( array(