__construct(); } function __construct() { global $bp; // Ensure that we have access to some utility functions. Must use require_once() // because BP Core is loaded during incremental upgrades require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); // Get current DB version $this->database_version = !empty( $bp->database_version ) ? (int) $bp->database_version : 0; if ( !empty( $bp->is_network_activate ) ) { $this->is_network_activate = $bp->is_network_activate; } elseif ( !$this->current_step() ) { setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH ); $_COOKIE['bp-wizard-step'] = 0; } $this->new_version = constant( 'BP_DB_VERSION' ); $this->setup_type = !empty( $bp->maintenance_mode ) ? $bp->maintenance_mode : ''; $this->current_step = $this->current_step(); // Remove the admin menu while we update/install remove_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 ); // Call the save method that will save data and modify $current_step if ( isset( $_POST['save'] ) ) $this->save( $_POST['save'] ); // Build the steps needed for update or new installations $this->steps = $this->add_steps(); } function current_step() { if ( isset( $_POST['step'] ) ) { $current_step = (int)$_POST['step'] + 1; } else { if ( !empty( $_COOKIE['bp-wizard-step'] ) ) $current_step = $_COOKIE['bp-wizard-step']; else $current_step = 0; } return $current_step; } function add_steps() { global $wp_rewrite; // Setup wizard steps $steps = array(); if ( 'install' == $this->setup_type ) { $steps = array( __( 'Components', 'buddypress' ), __( 'Pages', 'buddypress' ), __( 'Permalinks', 'buddypress' ), __( 'Theme', 'buddypress' ), __( 'Finish', 'buddypress' ) ); // Update wizard steps } else { if ( $this->is_network_activate ) $steps[] = __( 'Multisite Update', 'buddypress' ); if ( $this->database_version < (int) $this->new_version ) $steps[] = __( 'Database Update', 'buddypress' ); if ( $this->database_version < 1801 || !bp_core_get_directory_page_ids() ) { $steps[] = __( 'Components', 'buddypress' ); $steps[] = __( 'Pages', 'buddypress' ); } $steps[] = __( 'Finish', 'buddypress' ); } return $steps; } function save( $step_name ) { // Save any posted values switch ( $step_name ) { case 'db_update': default: $result = $this->step_db_update_save(); break; case 'ms_update': default: $result = $this->step_ms_update_save(); break; case 'ms_pages': default: $result = $this->step_ms_update_save(); break; case 'components': default: $result = $this->step_components_save(); break; case 'pages': default: $result = $this->step_pages_save(); break; case 'permalinks': default: $result = $this->step_permalinks_save(); break; case 'theme': default: $result = $this->step_theme_save(); break; case 'finish': default: $result = $this->step_finish_save(); break; } if ( !$result && $this->current_step ) $this->current_step--; if ( 'finish' != $step_name ) setcookie( 'bp-wizard-step', (int)$this->current_step, time() + 60 * 60 * 24, COOKIEPATH ); } function html() { // Update or Setup $type = ( 'update' == $this->setup_type ) ? __( 'Update', 'buddypress' ) : __( 'Setup', 'buddypress' ); ?>

steps ) - 1; $wiz_or_set = $this->current_step >= $step_count ? 'bp-general-settings' : 'bp-wizard'; $form_action = bp_core_update_do_network_admin() ? network_admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => $wiz_or_set ), 'admin.php' ) ); ?>
    steps as $i => $name ) : ?> current_step == $i ) : ?> class="current"> current_step > $i ) : ?>  
steps[$this->current_step] ) : ?>
steps[$this->current_step] ) { case __( 'Database Update', 'buddypress') : $this->step_db_update(); break; case __( 'Multisite Update', 'buddypress') : $this->step_ms_update(); break; case __( 'Site Directory', 'buddypress') : $this->step_ms_update(); break; case __( 'Components', 'buddypress') : $this->step_components(); break; case __( 'Pages', 'buddypress') : $this->step_pages(); break; case __( 'Permalinks', 'buddypress') : $this->step_permalinks(); break; case __( 'Theme', 'buddypress') : $this->step_theme(); break; case __( 'Finish', 'buddypress') : $this->step_finish(); break; } ?>

blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) switch_to_blog( bp_get_root_blog_id() ); if ( !current_user_can( 'activate_plugins' ) ) return false; $active_components = bp_get_option( 'bp-active-components' ); if ( defined( 'BP_BLOGS_SLUG' ) ) $blogs_slug = constant( 'BP_BLOGS_SLUG' ); else $blogs_slug = 'blogs'; // Call up old bp-pages to see if a page has been previously linked to Blogs $existing_pages = bp_get_option( 'bp-pages' ); if ( !empty( $existing_pages['blogs'] ) ) $existing_blog_page = '&selected=' . $existing_pages['blogs']; else $existing_blog_page = ''; ?>

Network Options.', 'buddypress' ), network_admin_url( 'settings.php' ) ); ?>

/

blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) switch_to_blog( bp_get_root_blog_id() ); if ( !current_user_can( 'activate_plugins' ) ) return false; $existing_pages = bp_core_update_get_page_meta(); // Provide empty indexes to avoid PHP errors with wp_dropdown_pages() $indexes = array( 'members', 'activity', 'groups', 'forums', 'blogs', 'register', 'activate' ); foreach ( $indexes as $index ) { if ( !isset( $existing_pages[$index] ) ) $existing_pages[$index] = ''; } if ( !empty( $existing_pages['blogs'] ) ) $existing_blog_page = '&selected=' . $existing_pages['blogs']; else $existing_blog_page = ''; // Get active components $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) ); // Check for defined slugs $members_slug = !empty( $bp->members->slug ) ? $bp->members->slug : __( 'members', 'buddypress' ); // Groups $groups_slug = !empty( $bp->groups->slug ) ? $bp->groups->slug : __( 'groups', 'buddypress' ); // Activity $activity_slug = !empty( $bp->activity->slug ) ? $bp->activity->slug : __( 'activity', 'buddypress' ); // Forums $forums_slug = !empty( $bp->forums->slug ) ? $bp->forums->slug : __( 'forums', 'buddypress' ); // Blogs $blogs_slug = !empty( $bp->blogs->slug ) ? $bp->blogs->slug : __( 'blogs', 'buddypress' ); // Register $register_slug = !empty( $bp->register->slug ) ? $bp->register->slug : __( 'register', 'buddypress' ); // Activation $activation_slug = !empty( $bp->activation->slug ) ? $bp->activation->slug : __( 'activate', 'buddypress' ); ?>

permalink settings page first, and complete this setup wizard later.', 'buddypress' ), admin_url( 'options-permalink.php' ) ); ?>
/archives/123

<?php _e( 'BuddyPress Default', 'buddypress' ); ?>

<?php _e( 'A BuddyPress theme', 'buddypress' ); ?>

<?php _e( 'Your existing theme', 'buddypress' ); ?>

setup_type ) ? __( 'setup', 'buddypress' ) : __( 'update', 'buddypress' ); ?>

database_version < 1801 ) $this->update_1_5(); // Update the active components option early if we're updating if ( 'update' == $this->setup_type ) bp_update_option( 'bp-active-components', $bp->active_components ); return true; } return false; } function step_ms_update_save() { global $wpdb; if ( isset( $_POST['submit'] ) ) { check_admin_referer( 'bpwizard_ms_update' ); if ( !$active_components = bp_get_option( 'bp-active-components' ) ) $active_components = array(); // Transfer important settings from blog options to site options $options = array( 'bp-db-version' => $this->database_version, 'bp-active-components' => $active_components, 'avatar-default' => get_option( 'avatar-default' ) ); bp_core_activate_site_options( $options ); if ( isset( $_POST['bp_components']['blogs'] ) ) { $active_components['blogs'] = 1; // Make sure that the pages are created on the bp_get_root_blog_id(), no matter which Dashboard the setup is being run on if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) switch_to_blog( bp_get_root_blog_id() ); // Move bp-pages data from the blog options table to site options $existing_pages = bp_get_option( 'bp-pages' ); $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages ); bp_update_option( 'bp-pages', $bp_pages ); if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) restore_current_blog(); bp_core_install( $active_components ); } bp_update_option( 'bp-active-components', $active_components ); return true; } return false; } function step_components_save() { if ( isset( $_POST['submit'] ) && isset( $_POST['bp_components'] ) ) { check_admin_referer( 'bpwizard_components' ); $active_components = array(); // Settings form submitted, now save the settings. foreach ( (array)$_POST['bp_components'] as $key => $value ) $active_components[$key] = 1; bp_update_option( 'bp-active-components', $active_components ); wp_cache_flush(); bp_core_install(); return true; } return false; } function step_pages_save() { global $wpdb; if ( isset( $_POST['submit'] ) && isset( $_POST['bp_pages'] ) ) { check_admin_referer( 'bpwizard_pages' ); // Make sure that the pages are created on the bp_get_root_blog_id(), no matter which Dashboard the setup is being run on if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) switch_to_blog( bp_get_root_blog_id() ); // Delete any existing pages $existing_pages = bp_core_update_get_page_meta( 'bp-pages' ); foreach ( (array)$existing_pages as $page_id ) wp_delete_post( $page_id, true ); $blog_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); bp_update_option( 'bp-pages', $blog_pages ); if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != bp_get_root_blog_id() ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) ) restore_current_blog(); return true; } return false; } function step_permalinks_save() { global $wp_rewrite, $current_site, $current_blog; // Prevent debug notices $iis7_permalinks = $usingpi = $writable = false; if ( isset( $_POST['submit'] ) ) { check_admin_referer( 'bpwizard_permalinks' ); $home_path = get_home_path(); $iis7_permalinks = iis7_supports_permalinks(); if ( isset( $_POST['permalink_structure'] ) ) { $permalink_structure = $_POST['permalink_structure']; if ( !empty( $permalink_structure ) ) $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] ); if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path ) $permalink_structure = '/blog' . $permalink_structure; $wp_rewrite->set_permalink_structure( $permalink_structure ); } if ( !empty( $iis7_permalinks ) ) { if ( ( !file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) { $writable = true; } } else { if ( ( !file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) { $writable = true; } } if ( $wp_rewrite->using_index_permalinks() ) $usingpi = true; $wp_rewrite->flush_rules(); if ( !empty( $iis7_permalinks ) || ( empty( $usingpi ) && empty( $writable ) ) ) { function _bp_core_wizard_step_permalinks_message() { global $wp_rewrite; ?>

web.config file were writable, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your web.config file. Click in the field and press CTRL + a to select all. Then insert this rule inside of the /<configuration>/<system.webServer>/<rewrite>/<rules> element in web.config file.' ); ?>

.htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.' ); ?>



.htaccess file in the root of your WordPress installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress' ); ?>

$plugin ) { if ( 'BuddyPress Template Pack' == $plugin['Name'] ) { activate_plugin( $key ); } } break; // Pick a theme from the repo case '3rd_party' : if ( empty( $_POST['3rd_party_theme'] ) ) return false; $theme = explode( ',', $_POST['3rd_party_theme'] ); switch_theme( $theme[0], $theme[1] ); break; // Keep existing theme case 'do_not_change' : return true; break; } if ( is_multisite() ) restore_current_blog(); return true; } return false; } function step_finish_save() { if ( isset( $_POST['submit'] ) ) { check_admin_referer( 'bpwizard_finish' ); // Update the DB version in the database // Stored in sitemeta. Do not use bp_update_option() update_site_option( 'bp-db-version', $this->new_version ); delete_site_option( 'bp-core-db-version' ); // Delete the setup cookie @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); // Load BP and hook the admin menu, so that the redirect is successful if ( !function_exists( 'bp_core_update_message' ) ) require( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-admin.php' ); bp_core_add_admin_menu(); // Redirect to the BuddyPress dashboard $redirect = bp_core_update_do_network_admin() ? add_query_arg( array( 'page' => 'bp-general-settings' ), network_admin_url( 'admin.php' ) ) : add_query_arg( array( 'page' => 'bp-general-settings' ), admin_url( 'admin.php' ) ); wp_redirect( $redirect ); return true; } return false; } function setup_pages( $pages ) { foreach ( $pages as $key => $value ) { if ( 'page' == $value ) { // Check for the selected page if ( !empty( $_POST['bp-' . $key . '-page'] ) ) $bp_pages[$key] = (int)$_POST['bp-' . $key . '-page']; else $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $key ), 'post_status' => 'publish', 'post_type' => 'page' ) ); } else { // Create a new page $bp_pages[$key] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $value ), 'post_status' => 'publish', 'post_type' => 'page' ) ); } } return $bp_pages; } // Database update methods based on version numbers function update_1_5() { // Delete old database version options delete_site_option( 'bp-activity-db-version' ); delete_site_option( 'bp-blogs-db-version' ); delete_site_option( 'bp-friends-db-version' ); delete_site_option( 'bp-groups-db-version' ); delete_site_option( 'bp-messages-db-version' ); delete_site_option( 'bp-xprofile-db-version' ); } /** * Reset the cookie so the install script starts over */ function reset_cookie() { @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); } } function bp_core_setup_wizard_init() { global $bp_wizard; $bp_wizard = new BP_Core_Setup_Wizard; } add_action( bp_core_update_admin_hook(), 'bp_core_setup_wizard_init', 7 ); function bp_core_install( $active_components = false ) { global $wpdb; if ( empty( $active_components ) ) $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) ); require( dirname( __FILE__ ) . '/bp-core-schema.php' ); // Core DB Tables bp_core_install_notifications(); // Activity Streams if ( !empty( $active_components['activity'] ) ) bp_core_install_activity_streams(); // Friend Connections if ( !empty( $active_components['friends'] ) ) bp_core_install_friends(); // Extensible Groups if ( !empty( $active_components['groups'] ) ) bp_core_install_groups(); // Private Messaging if ( !empty( $active_components['messages'] ) ) bp_core_install_private_messaging(); // Extended Profiles if ( !empty( $active_components['xprofile'] ) ) bp_core_install_extended_profiles(); // Blog tracking if ( !empty( $active_components['blogs'] ) ) bp_core_install_blog_tracking(); } function bp_core_update( $disabled ) { global $wpdb; require( dirname( __FILE__ ) . '/bp-core-schema.php' ); } function bp_update_db_stuff() { $bp_prefix = bp_core_get_table_prefix(); // Rename the old user activity cached table if needed. if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'" ) ) $wpdb->query( "RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" ); // Rename fields from pre BP 1.2 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) { if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) ) $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" ); if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) ) $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" ); } // On first installation - record all existing blogs in the system. if ( !(int)$bp->site_options['bp-blogs-first-install'] ) { bp_blogs_record_existing_blogs(); bp_update_option( 'bp-blogs-first-install', 1 ); } if ( is_multisite() ) bp_core_add_illegal_names(); // Update and remove the message threads table if it exists if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'" ) ) { $update = BP_Messages_Thread::update_tables(); if ( $update ) $wpdb->query( "DROP TABLE {$bp_prefix}bp_messages_threads" ); } } function bp_core_wizard_message() { if ( isset( $_GET['updated'] ) ) $message = __( 'Installation was successful. The available options have now been updated, please continue with your selection.', 'buddypress' ); else return false; ?>

'bp-wizard', 'updated' => '1' ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ); ?> setup_type ) ) return false; if ( !current_user_can( 'activate_plugins' ) ) return false; if ( 'install' == $bp_wizard->setup_type ) $status = __( 'Setup', 'buddypress' ); else $status = __( 'Update', 'buddypress' ); // Add the administration tab under the "Site Admin" tab for site administrators add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-wizard', '' ); $hook = add_submenu_page( 'bp-wizard', $status, $status, 'manage_options', 'bp-wizard', array( $bp_wizard, 'html' ) ); // Add a hook for css/js add_action( "admin_print_styles-$hook", 'bp_core_update_add_admin_menu_styles' ); } add_action( bp_core_update_admin_hook(), 'bp_core_update_add_admin_menu', 9 ); function bp_core_update_add_admin_menu_styles() { if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.dev.css' ), array(), '20110723' ); wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.dev.js' ), array( 'jquery' ), '20110723' ); } else { wp_enqueue_style( 'bp-admin-css', apply_filters( 'bp_core_admin_css', plugins_url( '/buddypress' ) . '/bp-core/css/admin.css' ), array(), '20110723' ); wp_enqueue_script( 'bp-update-js', apply_filters( 'bp_core_update_js', plugins_url( '/buddypress' ) . '/bp-core/js/update.js' ), array( 'jquery' ), '20110723' ); } wp_enqueue_script( 'thickbox' ); wp_enqueue_style( 'thickbox' ); ?> setup_type ) ) return; if ( !is_super_admin() ) return; if ( 'admin.php' == $pagenow && ( empty( $_GET['page'] ) || 'bp-wizard' == $_GET['page'] ) ) return; $url = bp_core_update_do_network_admin() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' ); switch( $bp_wizard->setup_type ) { case 'update': $msg = sprintf( __( 'BuddyPress has been updated! Please run the update wizard.', 'buddypress' ), $url ); break; default: case 'install': $msg = sprintf( __( 'BuddyPress was successfully installed! Please run the installation wizard.', 'buddypress' ), $url ); break; } echo '
' . $msg . '
'; } add_action( 'admin_notices', 'bp_core_update_nag', 5 ); add_action( 'network_admin_notices', 'bp_core_update_nag', 5 ); ?>